Convert a string to a byte array
string myString = "a test string";
byte[] myByteArray = new byte[myString.Length];
int i = 0;
foreach(char c in InStr.ToCharArray())
{
myByteArray [i] = (byte)c;
i++;
}
byte[] myByteArray = new byte[myString.Length];
int i = 0;
foreach(char c in InStr.ToCharArray())
{
myByteArray [i] = (byte)c;
i++;
}
Convert a byte array to a string
System.Text.Encoding enc = System.Text.Encoding.ASCII;
byte[] myByteArray = enc.GetBytes("a text string);
string myString = enc.GetString(myByteArray );
byte[] myByteArray = enc.GetBytes("a text string);
string myString = enc.GetString(myByteArray );
No comments:
Post a Comment