Abs Edward Ram Rose Sita
This is a C# Program to sort a list of names in alphabetical order.
This C# Program Sorts a List of Names in Alphabetical Order.
Here the List of names are sorted with the help of sort function.
Here is source code of the C# Program to Sort a List of Names in Alphabetical Order. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.
/* * C# Program to Sort a List of Names in Alphabetical Order */ using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication1 { class Program { static void Main() { List<string> names = new List<string>(); names.Add("Ram"); names.Add("Rose"); names.Add("Abs"); names.Add("Edward"); names.Add("Sita"); names.Sort(); foreach (string s in names) Console.WriteLine(s); Console.ReadLine(); } } }
In this C# program, using foreach loop print the names in alphabetical order. The foreach statement is used to iterate through the collection to get the information that we want, but cannot be used to add or remove items from the source collection to avoid unpredictable side effects. Print the sorted list of names in alphabetical order.
Abs Edward Ram Rose Sita