I'm not sure whether this is the thing you are looking for.... The sample undermentioned is in VB.NET, but it is easy to convert it to C#. Wish it helps. :) Dim s As String = "This is a string"
Dim c() As Char
Dim b() As Byte b = System.Text.ASCIIEncoding.ASCII.GetBytes(s)
c = System.Text.ASCIIEncoding.ASCII.GetChars(b)
Dim c() As Char
Dim b() As Byte b = System.Text.ASCIIEncoding.ASCII.GetBytes(s)
c = System.Text.ASCIIEncoding.ASCII.GetChars(b)
◎把字符串转化为字节流
string str="中国1234";
byte[] bwrite=Encoding.Default.GetBytes(str.ToCharArray());
◎把字节流转化为字符串
string str;
byte[] bStr=new byte[3]{48+7,48+8,48+9};
str=Encoding.Default.GetString(bStr);
MessageBox.Show(str);