日期:2014-05-18 浏览次数:20939 次
string str = "abcdef"; byte[] bs = Encoding.ASCII.GetBytes(str);
------解决方案--------------------
我跟过了,是61啊
------解决方案--------------------
string str = "abcdef";
char[] array = str.ToCharArray();
byte[] barray = new byte[array.Length];
for (int i=0;i<array.Length;i++)
{
barray[i] = (byte)array[i];
}
------解决方案--------------------
var array = "abcdef" .Select(x => (Byte)x) .ToArray();
------解决方案--------------------
unsafe static void Main(string[] args) { string str = "abcdef"; byte[] bs = new byte[str.Length]; for (int i = 0; i < str.Length; i++) { bs[i] = (byte)str[i]; Console.WriteLine("{0:x}", bs[i]); } }