下面是我在C#
中的字符串,我将它转换为字符数组&,需要获取字符串中每个字符的ASCII值。如何获取C#中字符的ASCII值
static void Main(string[] args)
{
string s = "Test";
var arr = s.ToCharArray();
foreach(var a in arr)
{
var n = Encoding.ASCII.GetByteCount(a.ToString());
Console.WriteLine(a);
Console.WriteLine(n);
}
}
此输出为
T
1
e
1
s
1
t
1
在谷歌上搜索我的链接数量,但他们没有足够我的需要。
- How to get ASCII value of string in C#
- https://www.codeproject.com/Questions/516802/ConvertingpluscharsplustoplusASCIIplusinplusC
我需要得到的字符串中每个字符的ASCII值。???
任何帮助/建议高度赞赏。
参见:http://stackoverflow.com/questions/5002909/getting -acc-sharp-string的字符值 – NoChance