Linq Articles

Found 6 articles

C# Program to Reverse the List of Cities using LINQ

Sabid Ansari
Sabid Ansari
Updated on 17-Mar-2026 357 Views

In C#, LINQ (Language Integrated Query) is a powerful feature that allows us to perform queries on various data sources, including arrays, lists, and databases. It provides an efficient and concise way to manipulate data and has become an essential tool for developers. In this article, we will explore how to use LINQ to reverse a list of cities in C#. LINQ is a set of extensions to the .NET Framework that provides a standard way to query data from different data sources using a common syntax. It allows developers to write queries that resemble SQL statements, making it ...

Read More

C# Program to Sort a List of Employees Based on Salary using LINQ

Sabid Ansari
Sabid Ansari
Updated on 17-Mar-2026 1K+ Views

In many software development projects, there comes a point where it becomes necessary to sort a list of objects based on one or more properties of the objects. In C#, the LINQ (Language Integrated Query) library provides a powerful and easy-to-use way to sort lists of objects based on one or more criteria. In this tutorial, we will demonstrate how to sort a list of Employee objects based on their salary using LINQ. Syntax Following is the syntax for sorting a list using LINQ OrderBy methods − // Sort in ascending order var sortedList = list.OrderBy(item ...

Read More

C# Program to Sort a List of String Names Using the LINQ OrderBy() Method

Sabid Ansari
Sabid Ansari
Updated on 17-Mar-2026 3K+ Views

Sorting a list of string names is a common task in programming, and the LINQ OrderBy() method in C# provides an elegant and efficient way to accomplish this. In this article, we will explore how to sort string lists using LINQ, including both ascending and descending order sorting. What is LINQ OrderBy() Method? The LINQ OrderBy() method is used to sort elements of a sequence in ascending order based on a specified key. For descending order, you use OrderByDescending(). These methods work with any IEnumerable collection and return an IOrderedEnumerable. Syntax Following is the syntax for ...

Read More

C# Program To Sort Student Names in Descending Order Using LINQ

Siva Sai
Siva Sai
Updated on 17-Mar-2026 385 Views

This tutorial demonstrates how to create a C# program that sorts student names in descending order using Language Integrated Query (LINQ). LINQ provides a powerful, readable way to query and manipulate data collections directly within C# code. Why Use LINQ for Sorting? LINQ offers several advantages over traditional sorting approaches − Readability − Clean, SQL-like syntax that's easy to understand Flexibility − Works with various data sources (collections, XML, databases) using the same syntax Abstraction − Focus on query logic rather than implementation details Lazy Evaluation − Query execution ...

Read More

Count the Number of Element Present in the Sequence in LINQ?

Siva Sai
Siva Sai
Updated on 17-Mar-2026 476 Views

Language Integrated Query (LINQ) is a powerful feature in C# that allows for efficient data manipulation. One common task when working with collections is determining the number of elements in a sequence. This article will guide you through using LINQ to count elements in various scenarios. Understanding LINQ Sequences A sequence in LINQ is any object that implements the IEnumerable or IEnumerable interface. This includes arrays, lists, collections, and query results. LINQ provides several methods to count elements efficiently. Syntax Following is the syntax for basic counting operations − // Count all elements int ...

Read More

Cross Join in LINQ

Siva Sai
Siva Sai
Updated on 17-Mar-2026 1K+ Views

Language Integrated Query (LINQ) is a powerful tool in C# for data manipulation, allowing for efficient and expressive data access and manipulation. One of the operations you can perform with LINQ is the cross join operation, which creates a Cartesian product between two data sources. Understanding Cross Join Cross join, also known as Cartesian product, is a type of join operation that matches each row of the first table with every row of the second table. If the first table has n rows and the second table has m rows, the result is a table with n×m rows. ...

Read More
Showing 1–6 of 6 articles
« Prev 1 Next »
Advertisements