LINQ in C#

 Introduction:

LINQ is known as the Line Integrated Query is a Microsoft technology use for performing operations on data on nearly every data source.

We use the LINQ queries to deal with data from various database systems, LINQ has a great support in C# as it supports to deal with data in Arrays, Lists, database, XML files and flat files.

In this example we will learn, how can we use the LINQ query for dealing with data using arrays or Lists,

In this article, we will use various LINQ queries to perform various operations at a given data.

We will consider different examples to evaluate the LINQ queries,

Example 1:

In this example we will print all the numbers in an array using the LINQ query, so lets at this example below,

Example 2:

Suppose if we want to print all the even numbers present in an array using LINQ, so lets have a look at this example below,

Example 3:

In this example, we will see how we can print out the numbers inside an array in descending order using LINQ, so lets have a look at this example below,


 Example 4:

In this example, we will see how to print out the nth highest number in an array, suppose we have an array and we want to print the 3rd highest number from that array using LINQ.


Example 5:

In this last example of the LINQ query, we will see how the sum all the odd numbers in a given array using LINQ, so lets have a look at this example below


  











  

Talha Mahmood

I have been developing Applications in Microsoft .NET technologies since 2015, and having more then 5 years of experience in .NET Technology and SQL database, also having hands in tools like C# Windows Forms, WPF, WCF, Asp.Net Web forms, Asp.Net Core, SSRS, LINQ, Entity Framework, Crystal Reports, SQL server, MySQL, MongoDB, Document DB, JQuery, JavaScript, Oracle, Web API.

Post a Comment

Previous Post Next Post