C# Sort String Array: Quick Code Guide
In C#, you can use the Sort method of the Array class to sort a string array. Here is an example code:
using System;
class Program
{
static void Main()
{
string[] names = { "Alice", "Bob", "Charlie", "David" };
Array.Sort(names);
foreach (string name in names)
{
Console.WriteLine(name);
}
}
}
Running the above code will output a sorted array of strings.
Alice
Bob
Charlie
David