in c#, how can i build up array from A to ZZ that is similar to the way that excel orders columns

后端 未结 10 1043
情深已故
情深已故 2020-12-18 00:48

i am looking for code that can generate an array where the first item is A, then B, then C . . .after Z i

10条回答
  •  生来不讨喜
    2020-12-18 01:17

    Here's one way. :)

    string[] values =
      Enumerable.Range(0, 27 * 26)
      .Select(
        n => new String(
          new[] { (char)('@' + n / 26), (char)('A' + n % 26) },
          n < 26 ? 1 : 0, n < 26 ? 1 : 2
        )
      )
      .ToArray();
    

提交回复
热议问题