C # simple conversion of letters, numbers, ASCII codes,
Convert letters to numbers
Byte [] array = new byte [1]; // defines an array
Array = System. Text. Encoding. ASCII. GetBytes (string); // string Conversion letter
Int asciicode = (short) (array [0]);/* Ask hovertree.com */
ASCII code = Convert. ToString (asciicode); // Convert the ASCII code to the string type
Convert numbers to letters
Byte [] array = new byte [1];
Array [0] = (byte) (Convert. ToInt32 (ASCII Code); // the ASCII code is forcibly converted to binary
Converted letters = Convert. ToString (System. Text. Encoding. ASCII. GetString (array ));
In the encoding process, indexes of some numbers are often used to convert to letters. For example, the number of columns of cells in Excel is represented by uppercase letters, to convert a number to a letter, use the GetString method in the ASCIIEncoding class of C. See the following example:
///// Convert a number to a letter // the number to be converted to a letter (the number range is []) // private string NunToChar (int number) {if (65 <= number & 90> = number) {System. text. ASCIIEncoding asciiEncoding = new System. text. ASCIIEncoding (); byte [] btNumber = new byte [] {(byte) number}; return asciiEncoding. getString (btNumber);} return "the number is not in the conversion range";} // set 1, 2, 3 ,..., 35, 36 to A, B, C ,..., y, Z // the number to be converted to a letter (the number range is [1, 36]) // private string NunberToChar (int number) {if (1 <= number & 36> = number) {int num = number + 64; System. text. ASCIIEncoding asciiEncoding = new System. text. ASCIIEncoding (); byte [] btNumber = new byte [] {(byte) num}; return asciiEncoding. getString (btNumber);} return "the number is not in the conversion range";}/* He asked hovertree.com */
Recommended: http://www.cnblogs.com/roucheng/p/netkuangjia.html