C# 中 提示“System.NullReferenceException”类型的未经处理的异常,未将对象引用设置到对象的实例、
publicbyte[]strToToHexByte(stringhexString){if(hexString.Contains(""))hexString=hexSt...
public byte[] strToToHexByte(string hexString)
{
if(hexString.Contains(" ")) hexString = hexString.Replace(" ", "");
if ((hexString.Length % 2) != 0)
hexString += " ";
byte[] returnBytes = new byte[hexString.Length / 2];
for (int i = 0; i < returnBytes.Length; i++)
returnBytes[i] = System.Convert.ToByte(hexString.Substring(i * 2, 2), 16);
return returnBytes;
} 展开
{
if(hexString.Contains(" ")) hexString = hexString.Replace(" ", "");
if ((hexString.Length % 2) != 0)
hexString += " ";
byte[] returnBytes = new byte[hexString.Length / 2];
for (int i = 0; i < returnBytes.Length; i++)
returnBytes[i] = System.Convert.ToByte(hexString.Substring(i * 2, 2), 16);
return returnBytes;
} 展开
7个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询