c# 字符转charCode
c#自带函数
//字符 -> charCode int charCode = char.ConvertToUtf32(str, 0); //charCode -> 字符 string ch = char.ConvertFromUtf32(charCode);
自己实现:字符 -> charCode
private static int GetCharCode(char c) { var bytes = Encoding.Unicode.GetBytes(new char[] { c }); int charCode = (int)bytes[1] << 8; charCode += (int)bytes[0]; return charCode; }