How to sort a C# List

Now we are going to learn about sorting a list in C#.
  • 3279

Introduction

C# does not provide a facility to re size the array in dynamically so we have a facility to increase the sizes that is called list. We have use the < and > for declare the list this is not symbol of the greater than or less than.
There is a facility to sort the string values in c#.

Example

class Program
{
static void Main()
{
List
<string> list = new List<string>();
list.Add("arjun");
list.Add("bablu");
list.Add("boss");
list.Add("vivek");
list.Add("himansu");
list.Add("surender");
list.Add("sandeep");
list.Reverse();
foreach
(string value in list)
{
Console
.WriteLine(value);
Console
.Read();
}
}
}
}

Output

listexample.jpg

© 2020 DotNetHeaven. All rights reserved.