在 VB.NET 中将 Byte 转换为 Char 时出现语法错误

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19064161/
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-17 15:16:28  来源:igfitidea点击:

Syntax error when converting Byte to Char in VB.NET

vb.netstringcharbyte

提问by Krazii KiiD

An error pops up when I write this:

当我写这个时弹出一个错误:

ListView1.Items(0).SubItems.Add(Convert.ToChar(byteData(i)))

The error is:

错误是:

Overload resolution failed because no accessible 'Convert' accepts this number of arguments.

重载解析失败,因为没有可访问的“Convert”接受此数量的参数。

回答by S.Serpooshan

the Convert.ToCharwill work for converting a byte to a char. for example the following cod will work without any problem:

Convert.ToChar会为一个字节转换为CHAR工作。例如,以下 cod 可以正常工作:

    Dim byteArray(10) As Byte
    byteArray(0) = 65 'code of 'A' char
    Dim ch As Char
    ch = Convert.ToChar(byteArray(0)) 'ch becomes 'A'c

Can you explai more about what type is byteData(i)in your code? maybe it is not a byte as you expected. please check it or give more info from where you have defined it?

你能详细解释一下byteData(i)你的代码是什么类型吗?也许它不是您预期的字节。请检查它或从您定义它的地方提供更多信息?