【发布时间】:2017-09-08 07:20:53
【问题描述】:
下面是我在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值???
非常感谢任何帮助/建议。
【问题讨论】:
标签: c# asp.net string character ascii