如何获取ASCII值的字符串在C# [英] How to get ASCII value of string in C#

查看:89
本文介绍了如何获取ASCII值的字符串在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



如果我的字符串的值为9quali52ty3,我想要一个ASCII码的ASCII码



如何在C#中获取ASCII值?

解决方案

MSDN

  string value =9quali52ty3; 

//将字符串转换为字节[]。
byte [] asciiBytes = Encoding.ASCII.GetBytes(value);

您现在有一个字符串的ASCII值数组。我得到以下内容:



57
113
117
97
108
105
53
50
116
121
51


I want to get the ASCII value of characters in a string in C#.

If my string has the value "9quali52ty3", I want an array with the ASCII values of each of the 11 characters.

How can I get ASCII values in C#?

解决方案

From MSDN

string value = "9quali52ty3";

// Convert the string into a byte[].
byte[] asciiBytes = Encoding.ASCII.GetBytes(value);

You now have an array of the ASCII value of the bytes. I got the following:

57 113 117 97 108 105 53 50 116 121 51

这篇关于如何获取ASCII值的字符串在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆