标签:class blog get string 问题 new
static byte[] GetBytes(string str)
{
byte[] bytes = new byte[str.Length * sizeof(char)];
System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);
return bytes;
}
static string GetString(byte[] bytes)
{
char[] chars = new char[bytes.Length / sizeof(char)];
System.Buffer.BlockCopy(bytes, 0, chars, 0, bytes.Length);
return new string(chars);
}
一般都需要先考虑字符编码后转换,而无需考虑编码问题
无需考虑编码问题string转byte的方法,布布扣,bubuko.com
标签:class blog get string 问题 new
原文地址:http://www.cnblogs.com/zfcflower/p/3804878.html