none
vb.net字节数组连接成16进制字符串

    问题

  • vb.net 如何用简单的函数将字节数组以十六进制格式连接成字符串?例如a(0)=CByte("&HCD"),a(1)=CByte("&HCC"),a(2)=CByte("&HC8"),a(3)=CByte("&H41")

    a(3)=CByte("&H41")连接成"41C8CCDD"


    
    2016年8月27日 14:48

答案

  • 你好,

    请参考以下代码

     Dim a As Byte() = New Byte(3) {}
            a(0) = CByte("&HCD")
            a(1) = CByte("&HCC")
            a(2) = CByte("&HC8")
            a(3) = CByte("&H41")
    
            Dim sb As New StringBuilder()
    
            For i As Integer = a.Length - 1 To 0 Step -1
                sb.Append(a(i).ToString("X"))
            Next
         
            Console.WriteLine(sb.ToString())

    Best regards,

    Cole Wu


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    2016年8月28日 3:15
    版主