C#中如何把byte[]数组转换成其他类型
2015-01-06 15:13
337 查看
http://bbs.csdn.net/topics/20447859
byte[] bytes = new byte[256];
//receive some stream from network
int a,b,c,d;
string theStr;
a = (int)bytes[0];
b = (int)bytes[1];
c = (int)bytes[2];
d = (int)bytes[3];
byte[] newBytes = byte[bytes.Length-4];
for( int i=0;i<newBytes.Length;i++ )
newBytes[i] = bytes[i+4];
theStr = System.Text.Encoding.Default.GetString( newBytes ); //注意你接受的字符串的编码,根据编码这里要使用不同的编码来获得字符串
//如果字符串是已','分割
string[] stringValues = theStr.Split( ',' );
//stringValues这个数组就是分割后的各个字符串
byte[] bytes = new byte[256];
//receive some stream from network
int a,b,c,d;
string theStr;
a = (int)bytes[0];
b = (int)bytes[1];
c = (int)bytes[2];
d = (int)bytes[3];
byte[] newBytes = byte[bytes.Length-4];
for( int i=0;i<newBytes.Length;i++ )
newBytes[i] = bytes[i+4];
theStr = System.Text.Encoding.Default.GetString( newBytes ); //注意你接受的字符串的编码,根据编码这里要使用不同的编码来获得字符串
//如果字符串是已','分割
string[] stringValues = theStr.Split( ',' );
//stringValues这个数组就是分割后的各个字符串
相关文章推荐
- C# byte数组转换string类型如何去掉结束符
- c#中数组,类型转换,using语句的其他用法
- C#枚举类型、枚举类型与其他类型转换、结构类型、数组类型
- 使用C#将Byte数组中含有的BCD码转换成字符串,及如何将字符串转换成BCD码
- 如何:将字节数组转换为 基本类型(C# 编程指南)
- C#中将Object数组转换为String(或者其他类型)的数组(集合)
- 如何将int类型数据转换成byte数组
- C#中将DateTime类型转换成Byte数组
- c#中如何将byte数组转换成string从而在textbox中显示出来?
- c# .net 如何把byte类型仅仅转换成string而不改变其内容
- c# string和byte数组相互转换
- 在C#中将任意数值类型数据与字节数组相互转换的一个方法
- 在C#中如何使用BYTE[]转换为String
- 比如将一个变量转换到INT类型 C#.NET中如何进行强制类型转换
- C#中将byte数组转换为8bit灰度图像
- C#中如何将字符串转换byte[],同时如何将byte[]换成字符串?
- byte与其他类型之间的强制转换
- C#中将Byte数组转化成DateTime类型
- C#问题--如何转换数组的类型
- byte与其他类型的转换