Difference between Comprehension Queries and lamda queries

Comprehension Queries are used for user friendly, but the thing is there query are converted into lamda internally for execution. So lamda expressions are fast.

Comprehension queries:

int[] array = new int[7] { 0, 1, 2, 3, 4, 5, 6 };

                var query = (from no in array

                            where (no % 3 == 0)

                            select no).ToArray();

                foreach (int no in query)

                {

                                Console.WriteLine("{0,1}", no);

                }             

Lamda Queries:

string[] stringarray = { "How", "are", "you" };

                IEnumerable<string> result = Enumerable.Where(stringarray, o => o.Length == 3);        

                foreach (string res in result)

                                Console.WriteLine(res);

Ebook Download
View all
Learn
View all