摘要:[C#] String to Byte
string teststring = "2;a;b;c;d;e";
byte[] temp = System.Text.Encoding.Default.GetBytes(teststring.Replace(";",""));
Console.WriteLine("count:" + temp.Count());
for (int i = 0; i < temp.Count(); i++)
{
Console.WriteLine("data:" + temp[i]);
}
Console.WriteLine("teststring:" + System.Text.Encoding.Default.GetString(temp));
output
count:6
data:50
data:97
data:98
data:99
data:100
data:101
teststring:2abcde