Tag: List
How to convert Array to List in Java ?
This article will explain how to convert a simple array to list in Java . How to convert Array to List in Java ? The Java’s array class provides necessary methods to convert the array to the List using the asList method. Below is a sample code snippet demonstrating the usage of the Arrays.asList method to convert array to List.
How to make a Type Sortable in C# using IComparable interface?
Assume that you have a type which would be stored in a List. You would want to use List.Sort method to sort your data in the List. For example , assume that you have to store objects of type Employee in List<Employee> and sort the List by Age using the Sort method. To do this , we can use he IComparable<T> interface. How to make…
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#?
How to Clone a Generic List in C#?
Below is a sample code snippet that demonstrates how to clone a generic list in C#. How to Clone a Generic List 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.
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#?
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 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#?
How to Split List into Sub list in C# using LINQ ?
If you want to split the generic list in to sub list in C# , one of the simplest way is to use LINQ (Language Integrated Query). Below is a code sample demonstrating this feature. How to Split List into Sub list in C# using LINQ ?
How to Create Comma Separated Strings from List of Strings in C#?
Below is a sample code snippet that demonstrates how one can easily create the comma separated strings from List<string> in C#. How to Create Comma Separated Strings from List of Strings in C#?
How to Get the Top 5 elements from a List in C# ?
If you want to get the top 5 elements from a list in C# or skip the first item and get the next five elements from a List , you can use the Take and the Skip methods. How to Get the Top 5 elements from a List in C# ? Below is a sample code snippet demonstrating the usage of the Skip and Take…
How to retrieve all Rows of the DataTable to a List in C#?
Below is a sample sourecode demonstrating how to retrieve all rows of the DataTable to a list in C#. How to retrieve all Rows of the DataTable to a List in C#?
Convert All Strings in a List to Upper Case using LINQ in C#
Below is a sample code snippet which demonstrates on how to convert all strings in a list to upper case using LINQ in C#.
?
How to Add item to the beginning of List in C# ?
If you want to add or insert an item to the beginning of the List in C# , you can use the Insert method defined in the collection as shown below. How to Add item to the beginning of List in C# ? using System; using System.Collections.Generic; using System.Linq; namespace ACCode { class Program { static void Main(string[] args) { …
How to List out only Even Numbers from a List of Integers using Lambda Expression in C#?
Below is sample code snippet that demonstrates how to list out only even numbers from a list of integers using Lambda Expression in C#. How to List out only Even Numbers from a List of Integers using Lambda Expression in C#?
How to List Odd Numbers from a List of Integers using Lambda Expression in C#?
Are you looking out for a simple logic to retrieve the odd numbers from the list of integers using Lambda Expression in C#? Below is a sample code snippet demonstrating how to do it. How to List Odd Numbers from a List of Integers using Lambda Expression in C#?
How to Remove Objects from the List with RemoveAll in C#?
Below is a sample code snippet demonstrating How to Remove Objects from the List with RemoveAll in C#? How to Remove Objects from the List with RemoveAll in C#?
How to select top 5 records from List using LINQ in C#?
Below is a sample code snippet demonstrating on how to select top 5 records from a list using LINQ in C# using the Take extension method… How to select top 5 records from List using LINQ in C#?
How to Get the Maximum value from a List of String using LINQ in C# ?
In one of the previous article , we explained how to get the maximum value from a list of integer using LINQ query in C# . What happens when the column is a string instead of integer ?. Below are 2 possibilities on how to get the maximum value from a list of string. How to Get the Maximum value from a List of String…