' VB.Net 把byte array轉成String
Dim b As Byte() = {65, 66, 67, 68, 69, 70, 71}
Dim str As String
Dim enc As New System.Text.ASCIIEncoding()
Response.Write(enc.GetString(b))

' VB.Net 把String 轉成byte array
Dim encAs New System.Text.ASCIIEncoding()
Dim b As Byte() = enc.GetBytes("ABCDEFG")
For i As Integer = 0 To b.Length - 1
Response.Write(b(i).ToString()+",")
Next

' 將字串轉成byte陣列
Shared Function StrToByteArray(ByVal str As String) As Byte()
    Dim encoding As New System.Text.ASCIIEncoding()
    Return encoding.GetBytes(str)
End Function

' 將byte陣列轉成字串
Shared Function ByteArrayToStr(ByVal bt As Byte()) As String
    Dim encoding As New System.Text.ASCIIEncoding()
    Return encoding.GetString(bt)
End Function


arrow
arrow
    全站熱搜
    創作者介紹
    創作者 Roger 的頭像
    Roger

    歡迎~ 程式設計 學生 作業 專題製作 程式外包 家教...

    Roger 發表在 痞客邦 留言(0) 人氣()