C# Query ExpressionC# Query Expression is an expression that is written by using LINQ query syntax. The LINQ (Language Integrated Query) is a language that is used to construct a query. C# Query Expression contains set of clauses and use query expression similar to SQL. Query expression must start with from clause and end with a select or group clause. To store the query, we must use IEnumerable type variable. It provides a IEnumerator.MoveNext method to iterate elements. We can iterate elements from the IEnumerable sequence by using two ways.
Note: We must use System.Linq namespace to execute query expression.Let's see an example that displays odd numbers from the array by using the expression query. C# Query Expression Example 1Output 1 3 5 7 9 C# Query Expression Example 2In this example, we are using query expression to fetch student name from the collection of students. It displays a student, having student id 103. Output John Next TopicC# Partial Method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India