Tag: LINQ
How to use Find method with Lambda Expressions in C#?
Below is a sample source code demonstrating how to use Find method with Lambda Expression in C# How to use Find method with Lambda Expressions in C#?
Example of Anonymous Type Indexes in For Loop in C#
The anonymous type (var) can be used to initialize the indexes in a for loop or the object within the for each loop. Below is a sample code snippet demonstrating the usage of the anonymous types in the For loop . Example of Anonymous Type Indexes in For Loop in C#
VB.NET and LINQ – Filter elements from object collection with Logical Operators
Here’s a sample code snippet demonstrating how to filter elements from a list of objects using the where clause using LINQ in VB.NET. This sample gets all the employees who salary is greater than 20000 GBP and age is greater than 22. How to Filter Employees List whose salary is greater than 20000 GBP and age is greater than 22 using LINQ in VB.NET ?…
How to List Odd Numbers from a List of Integers using LINQ Query in C#?
Are you looking out for a simple logic to retrieve the odd numbers from the list of integers using LINQ Query in C#? Below is a sample code snippet demonstrating how to do it. How to List Odd Numbers from a List of Integers using LINQ Query in C#?
C# and LINQ – Filter elements from object collection with Logical Operators
Here’s a sample code snippet demonstrating how to filter elements from a list of objects using the where clause using LINQ in C#. This sample gets all the employees who salary is greater than 20000 GBP and age is greater than 22. How to Filter Employees List whose salary is greater than 20000 GBP and age is greater than 22 using LINQ in C# ?…
How to Apply LINQ Distinct on a particular property in C#?
Do you want to get the distinct records from a list based on a particular property using LINQ in C#?. Below is a code snippet that demonstrates how to do it. How to Apply LINQ Distinct on a particular property in C#?
How to Get the Last N Elements from a List using LINQ in C#?
Below is a sample code snippet demonstrating how to retrieve last N Elements (2) from a list in C# using LINQ.
Deferred Execution Example in LINQ and C#
The Query Operators are executed only when enumerated except few scenarios. For example, when you use the for/Foreach statement and iterate the items from the query result. Below is a sample code demonstrating the Deferred Execution in C#. Deferred Execution Example in LINQ and C#
How to List out Even Numbers from a List of Integers using LINQ in C#?
Below is sample code snippet that demonstrates how to list out only even numbers from a list of integers using LINQ? How to List out Even Numbers from a List of Integers using LINQ in C#?
Example of Immediate Query Execution of LINQ in C# .NET
Below is a sample code snippet that demonstrates the Immediate Query execution of LINQ Query in C#. Example of Immediate Query Execution of LINQ in C# .NET The Output of the above program in
C# and LINQ – Finding all the elements of an integer array less than 35
Here’s a sample code snippet demonstrating how to find all the elements of an integer array that is less than 35 using LINQ in C#. The where keyword in C# is used to filter the elements from a collection based on the specified criteria. Ensure that you import the System.Linq namespace to your C# code. How to find all the elements of an integer array…
Concatenate or Join a string Array using LINQ in C#
Want to join the items inside the string array say with, delimiter using LINQ in C#? It’s pretty easy. Below is a sample code snippet demonstrating in easy steps on how to concatenate a string array using LINQ in C#? Concatenate or Join a string Array using LINQ in C#
VB.NET and LINQ – Finding all the elements of an integer array less than 35
Here’s a sample code snippet demonstrating how to find all the elements of an integer array that is less than 35 using LINQ in Visual Basic.NET. The where keyword in VB.NET is used to filter the elements from a collection based on the specified criteria. How to find all the elements of an integer array less than 35 using LINQ in VB.NET ? The output…
How to Get the Max Value from a List of Integer using LINQ Query in C#?
One of the easiest way to get the Max value from a List of Integer in C# is to use LINQ extension method. The LINQ in C# provide the Max method which can be used to retrieve the Max Value from the List. How to Get the Max Value from a List of Integer using LINQ Query in C#?
How to merge two lists using LINQ’s Union in C#?
Below is a sample code snippet demonstrating in simple steps on how to merge two lists using LINQ’s Union extension method in C#? How to merge two lists using LINQ’s Union in C#?
How to Implement Multiple order by in LINQ using C#?
There are scenarios where one might want to implement multiple order by statements when using LINQ in C#. For example, you might want to sort the list of article by category and then by date. Below is a sample code snippet that demonstrates how to How to Implement Multiple order by in LINQ using C# ? How to Implement Multiple order by in LINQ using…
How to Remove Duplicates and Get Distinct records from List using LINQ?
Below is a sample source code demonstrating on how to remove duplicates and get distinct records in List using LINQ and C#?
How to select unique names from a List using LINQ in C#?
Below is a sample code snippet demonstrating on how to get unique or distinct names from a list in C# using LINQ query. How to select unique names from a List using LINQ in C#?
SelectMany Example in LINQ and C#
Below is a sample source code demonstrating the usage of the SelectMany method in LINQ and C#. One of the usage of the SelectMany is to return the flat list an avoid returning the lists of lists. SelectMany Example in LINQ and C#