I am porting a Delphi application in C #. One of the blocks has an ad like this:
const IdentChars = ['a'..'z', 'A'..'Z', '_'];
I did not find a similar declaration syntax for C #.
This is the best I could come up with:
char[] identFirstChars; // = ['a'..'z', 'A'..'Z', '_']; int size = (int)'z' - (int)'a' + 1 + (int)'Z' - (int)'A' + 1 + 1; identFirstChars = new char[size]; int index = 0; for(char ch = 'a'; ch <= 'z'; ch = (char)((int)(ch) + 1)) { identFirstChars[index] = ch; index++; } for (char ch = 'A'; ch <= 'Z'; ch = (char)((int)(ch) + 1)) { identFirstChars[index] = ch; index++; } identFirstChars[index] = '_';
There should be a more efficient way.
source share