String.ToCharArray() 存储在 StringCollection 中转换为数字并返回到 VB.net
我有一个字符串,已转换为字符数组并存储在字符串集合中,如何返回每个字符串中字符的数值?如何反转这个过程,从数值中获取字符?
我知道我可以编写一个 Select Case
语句,但这需要很长时间,因为我需要涵盖人们可能想要在英语中使用的每个字符,包括标点符号。
vb.net 中是否已经内置了一个方法来执行此操作?
感谢您的帮助!
I have a string which was converted to a char array and stored in a stringcollection, how do I return the numerical value for the character in each string? How can I reverse this process, getting the character from the numerical value?
I know I could code a Select Case
statement, but that would take a very long time as I need to cover every character a person could want to conceivably use in the English language, including punctuation.
Is there already a method built into vb.net for doing this?
Thanks for the help!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Convert
类具有可在字符和整数之间进行转换的方法:要将字符串中的字符转换为整数数组的值循环:
The
Convert
class has methods that can convert between characters and integers:To loop the values converted from the characters in a string into an array of integers:
尝试这样的操作:
请记住,
System.String
实现了IEnumerable
,因此对它进行For Each
是合法的。字符和数字之间的转换就像在System.Char
和System.Int32
之间进行转换一样简单(这里我展示了如何获取每个字符的数值)字符串)。Try something like this:
Remeber that
System.String
implementsIEnumerable<Char>
so it is legal toFor Each
over it. And converting between a character and a number is as simple as casting betweenSystem.Char
andSystem.Int32
(here I have shown how to get the numeric value for each character in the string).