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 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 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 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…