Abs Edward Ram Rose Sita
Users Online
· Guests Online: 14
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
· Members Online: 0
· Total Members: 188
· Newest Member: meenachowdary055
Forum Threads
Newest Threads
No Threads created
Hottest Threads
No Threads created
Latest Articles
Articles Hierarchy
C# Program to Sort a List of Names in Alphabetical Order
C# Program to Sort a List of Names in Alphabetical Order
This is a C# Program to sort a list of names in alphabetical order.
Problem Description
This C# Program Sorts a List of Names in Alphabetical Order.
Problem Solution
Here the List of names are sorted with the help of sort function.
Program/Source Code
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(); } } }
Program Explanation
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.
Runtime Test Cases
Comments
No Comments have been Posted.
Post Comment
Please Login to Post a Comment.