C#下byte数组与string的相互转换
2009-07-27 16:33
621 查看
1,string字符串转化为byte数组,ASCII码格式。
源代码如下:
2,byte数组转换为string字符串,ASCII码格式。
源代码如下:
3,string字符串转化为byte数组,Unicode格式。
源代码如下:
4,byte数组转换为string字符串,Unicode码格式。
源代码如下:
源代码如下:
//定义变量 byte[] Temp; string strTemp="你好"; int iLen=0; //转换 Temp = new ASCIIEncoding().GetBytes(strTemp); //得到转换后数组的大小 iLen=Temp.GetLength(0);
2,byte数组转换为string字符串,ASCII码格式。
源代码如下:
//定义临时变量 byte[] Temp = new byte[128]; string strTemp; //转换 ASCIIEncodingencoding = new ASCIIEncoding(); strTemp = encoding.GetString(Temp, 0, 128);
3,string字符串转化为byte数组,Unicode格式。
源代码如下:
//定义变量 byte[] Temp; string strTemp="你好"; int iLen=0; //转换 Temp=UnicodeEncoding().GetBytes(strTemp); //得到转换后数组的小 iLen=Temp.GetLength(0);
4,byte数组转换为string字符串,Unicode码格式。
源代码如下:
//定义临时变量 byte[] Temp = new byte[128]; string strTemp; //转换 UnicodeEncoding= new UnicodeEncoding(); strTemp = encoding.GetString(Temp, 0, 128);
相关文章推荐
- C# 字符串string和内存流MemoryStream及比特数组byte[]之间相互转换
- C#.NET中string与byte数组的相互转换
- c# string和byte数组相互转换
- C# 字符串string和内存流MemoryStream及比特数组byte[]之间相互转换
- C#下byte数组与string的相互转换
- c#中 uint--byte[]--char[]--string相互转换汇总
- C# String 与 Ushort[] 数组 相互转换
- C# byte[]类型和String类型相互转换
- C# string类型和byte[]类型相互转换
- C#图像处理:Stream 与 byte[] 相互转换,byte[]与string,Stream 与 File 相互转换等
- C#中List〈string〉和string[]数组之间的相互转换-
- [C#]image与byte数组的相互转换
- c#中 uint--byte[]--char[]--string相互转换汇总
- C#中string[]数组和list<string>泛型的相互转换 【转】
- 【C#】byte[]数组中有值大于127时与string之间的相互转化
- byte[]数组与string相互转换
- c#中 uint--byte[]--char[]--string相互转换汇总
- c#中 uint--byte[]--char[]--string相互转换汇总
- c#中 uint--byte[]--char[]--string相互转换汇总
- C# string byte数组转换解析