Is there an easy way to generate an array containing the letters of the alphabet in C#? It\'s not too hard to do it by hand, but I was wondering if there was a built in way
Note also, the string has a operator[] which returns a Char, and is an IEnumerable
, so for most purposes, you can use a string as a char[]. Hence:
string alpha = "ABCDEFGHIJKLMNOPQRSTUVQXYZ";
for (int i =0; i < 26; ++i)
{
Console.WriteLine(alpha[i]);
}
foreach(char c in alpha)
{
Console.WriteLine(c);
}