//整数到字节数组的转换
public static byte[] intToByte(int number) {
int temp = number;
byte[] b=new byte[4];
for (int i=b.length-1;i>-1;i--){
b[i] = new Integer(temp&0xff).byteValue(); //将最高位保存在最低位
temp = temp >> 8; //向右移8位
}
return b;
}b[i] = new Integer(temp&0xff).byteValue(); 在vs2005中 报错啊??
没有integer 这个类型???
public static byte[] intToByte(int number) {
int temp = number;
byte[] b=new byte[4];
for (int i=b.length-1;i>-1;i--){
b[i] = new Integer(temp&0xff).byteValue(); //将最高位保存在最低位
temp = temp >> 8; //向右移8位
}
return b;
}b[i] = new Integer(temp&0xff).byteValue(); 在vs2005中 报错啊??
没有integer 这个类型???
解决方案 »
- 【求助】C#接口继承和多态问题
- c# winform datagridview 列自定义控件
- C#截取特定的字符串
- 请教C#中的一个SQL语句~!
- MyGeneration连接Oracle时的问题?
- 请问:TcpListener类的AcceptTcpClient()方法,与AcceptSocket()方法,有什么不同使用地方呢?
- 讨论:基类问题,子类窗体统一继承通过变量传递调用基类窗体控件好? 还是子类窗体通过接口实例化基类窗体好?
- 关于C#的资源文件的问题,散100分!!!
- 请教:通过编码向网站发送POST请求,如何解决SESSION丢失的问题?
- C#操作Excel的速度为什么很慢
- 如何尝试2次操作,然后catch()???
- 傳多個不同的參數到sql中
int u1 = 300;
byte[] buffer = BitConverter.GetBytes(u1); //int类型,转换为byte数组
for (int i = 0; i < buffer.Length; i++)
{
Console.WriteLine("buffer[{0}]={1}",i,buffer[i]);
}
int u2 = BitConverter.ToInt32(buffer, 0); //byte数组转化为int
Console.WriteLine("u2={0}",u2);