如何在C#中获取字符串的ASCII值

编程入门 行业动态 更新时间:2024-10-25 12:24:12
本文介绍了如何在C#中获取字符串的ASCII值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我想在 C# 中获取字符串中字符的 ASCII 值.

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

如果我的字符串值为9quali52ty3",我想要一个包含 11 个字符中每个字符的 ASCII 值的数组.

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

如何在 C# 中获取 ASCII 值?

How can I get ASCII values in C#?

推荐答案

来自 MSDN

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

您现在有一个字节的 ASCII 值数组.我得到以下信息:

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

5711311797108105535011612151

57 113 117 97 108 105 53 50 116 121 51

更多推荐

如何在C#中获取字符串的ASCII值

本文发布于:2023-11-16 16:22:17,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1605903.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   如何在   ASCII

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!