将字符代码转换为字符 (VB.NET)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4857866/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 15:15:35  来源:igfitidea点击:

Converting a character code to char (VB.NET)

vb.netcharacter-encodingasciicharactercharacter-codes

提问by Freesn?w

I'm able to convert a character to its corresponding character/ASCII code using "Asc(CHAR)". What can I use to convert this returned integer back to its original character form?

我可以使用“Asc(CHAR)”将字符转换为其相应的字符/ASCII 代码。我可以使用什么将返回的整数转换回其原始字符形式?

回答by Jason Yost

The Chrfunction in VB.NET converts the integer back to the character:

ChrVB.NET 中的函数将整数转换回字符:

Dim i As Integer = Asc("x") ' Convert to ASCII integer.
Dim x As Char = Chr(i)      ' Convert ASCII integer to char.

回答by The Scrum Meister

Use the Chr or ChrWfunction, Chr(charNumber).

使用Chr 或 ChrW函数,Chr(charNumber)

回答by Georg

you can also use

你也可以使用

Dim intValue as integer = 65  ' letter A for instance
Dim strValue As String = Char.ConvertFromUtf32(intValue)

this doesn't requirement Microsoft.VisualBasic reference

这不需要 Microsoft.VisualBasic 参考

回答by AlexJF

You could use the Chr(int) function

您可以使用 Chr(int) 函数