Get Letters in Alphabet with C#

C# 15.3.2009 No Comments

Have you ever needed to do something with the letters of the alphabet? This is quite common in navigation systems where you have alot of data and need to break up things into sections alphabetically. You can always create an ArrayList and populate each section manually, but a better way is to just use the ASCII characters and put it into an array.

C#
public ArrayList GetAlphabet()
{
ArrayList list = new ArrayList();

for (int i = 65; i <= 90; i++)
{
list.Add(((char)i).ToString());
}
return list;
}

VB.NET
Public Function GetAlphabet() As ArrayList
Dim list As New ArrayList()

For i As Integer = 65 To 90
list.Add(CChar(i).ToString())
Next
Return list
End Function

Leave a Reply