Quickest way to enumerate the alphabet

后端 未结 7 667
猫巷女王i
猫巷女王i 2020-11-29 02:15

I want to iterate over the alphabet like so:

foreach(char c in alphabet)
{
 //do something with letter
}

Is an array of chars the best way

相关标签:
7条回答
  • 2020-11-29 02:56

    You could do this:

    for(int i = 65; i <= 95; i++)
    {
        //use System.Convert.ToChar() f.e. here
        doSomethingWithTheChar(Convert.ToChar(i));
    }
    

    Though, not the best way either. Maybe we could help better if we would know the reason for this.

    0 讨论(0)
提交回复
热议问题