29/09/2018
Chuyển từ string sang mảng byte

VB.NET
Imports System.Text

Public Shared Function ConvertStringToByteArray(ByVal stringToConvert As String) As Byte()

    Return (New UnicodeEncoding).GetBytes(stringToConvert)

End Function

C#
public static byte[] ConvertStringToByteArray(string stringToConvert)

{

return (new ASCIIEncoding()).GetBytes(stringToConvert);

}
 

C#

using System.Text;

 public static byte[] ConvertStringToByteArray(string stringToConvert)

{

    return (new UnicodeEncoding()).GetBytes(stringToConvert);

}