How do I convert integers to characters in C#?
Posted
by Mike Webb
on Stack Overflow
See other posts from Stack Overflow
or by Mike Webb
Published on 2010-04-12T19:01:56Z
Indexed on
2010/04/12
19:12 UTC
Read the original article
Hit count: 372
I am trying to convert an index of 1 to 27 into the corresponding uppercase letter. I know that in C++ I could type this:
char letter = 'A' + (char)(myIndex % 27);
This same code does not work in C#. How can I accomplish this task in C#?
EDIT: I'd rather not have to encode an enum or switch statement for this if there is a better mathematical solution like the one above.
© Stack Overflow or respective owner