●byte → char
byte[] byte1 = new byte[5]{0x01,0x02,0x03,0x04,0x05};
char[] char1 = Encoding.ASCII.GetChars(byte1);
●char → byte
char[] char1 = new char[5]{a,b,c,d,e};
byte[] byte1 = Encoding.Default.GetBytes(char1 );
●string → char[]
string string1 = "abcde";
char[] char1 = string1.ToCharArray();
●string → byte[]
string string1 = "abcde";
byte[] byte1 = Encoding.UTF8.GetBytes(string1);
●byte[] → string
byte[] byte1 = new byte[5] { 0x31, 0x32, 0x33, 0x34, 0x35 };
string string1 = Encoding.UTF8.GetString(byte1);
沒有留言:
張貼留言