📄 test.cs
字号:
using System;
using System.Collections.Generic;
using System.Text;
namespace testCpp2
{
public class BIConvert //字节 整形 转换类 网络格式转换为内存格式
{
public static byte[] Int2Bytes(uint i) //转换整形数据网络次序的字节数组
{
byte[] t = BitConverter.GetBytes(i);
byte b = t[0];
t[0] = t[3];
t[3] = b;
b = t[1];
t[1] = t[2];
t[2] = b;
return (t);
}
public static uint Bytes2UInt(byte[] bs, int startIndex) //返回字节数组代表的整数数字,4个数组
{
byte[] t = new byte[4];
for (int i = 0; i < 4 && i < bs.Length - startIndex; i++)
{
t[i] = bs[startIndex + i];
}
byte b = t[0];
t[0] = t[3];
t[3] = b;
b = t[1];
t[1] = t[2];
t[2] = b;
return (BitConverter.ToUInt32(t, 0));
}
public static uint Bytes2UInt(byte[] bs) //没有指定起始索引
{
return (Bytes2UInt(bs, 0));
}
public static void DumpBytes(byte[] bs, string txt)
{
System.IO.StreamWriter sw = new System.IO.StreamWriter(txt,true);
for (int i = 0; i < bs.Length; i++)
{
byte b = bs[i];
sw.WriteLine(b.ToString() + " ");
}
sw.WriteLine("-----" + DateTime.Now.ToLocalTime());
sw.Close();
}
public static void DebugString(string bs, string txt)
{
System.IO.StreamWriter sw = new System.IO.StreamWriter(txt);
sw.WriteLine(bs);
sw.WriteLine("-----" + DateTime.Now.ToLocalTime());
sw.Close();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -