C# hex to ascii

前端 未结 4 533
有刺的猬
有刺的猬 2020-12-03 14:05

I\'m trying to convert a String of hex to ASCII, using this:

public void ConvertHex(String hexString)
{
    StringBuilder sb = new StringBuilder();

    for          


        
4条回答
  •  一整个雨季
    2020-12-03 14:40

    Since you are incrementing your index by 2, you need to stop your loop one-before-the-end of the length of the string. Otherwise your last iteration of the loop will try to read characters past the end of the string.

    for (int i = 0; i < hexString.Length - 1, i += 2)
    

提交回复
热议问题