Quickest way to enumerate the alphabet

后端 未结 7 698
猫巷女王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:45

    I found this:

    foreach(char letter in Enumerable.Range(65, 26).ToList().ConvertAll(delegate(int value) { return (char)value; }))
    {
    //breakpoint here to confirm
    }
    

    while randomly reading this blog, and thought it was an interesting way to accomplish the task.

提交回复
热议问题