public static string ByteToString(byte[] InBytes)
{
string StringOut="";
foreach (byte InByte in InBytes)
{
StringOut=StringOut + String.Format("{0:X2} ",InByte);
}
return StringOut;
}
{
string StringOut="";
foreach (byte InByte in InBytes)
{
StringOut=StringOut + String.Format("{0:X2} ",InByte);
}
return StringOut;
}
public static string ByteToString(byte[] InBytes)
{
string StringOut="";
foreach (byte InByte in InBytes)
{
kao.Append( String.Format("{0:X2} ",InByte));
}
return kao.ToString();
}
把string 改成System.Text.StringBuilder 这样的话速度应该会块很多
FileStream fs=new FileStream(path1,FileMode.Open);//path1是文件路径
BinaryReader br=new BinaryReader(fs,System.Text.Encoding.GetEncoding("GB2312"));
while(true)
{
//这里我放了一些别的控制
this.setb(br.ReadUInt16(),((ushort)this.numericUpDown1.Value))
//setb是我的一个过程,你要的部分是br.ReadUInt16(),或类似的,主要看你要取出来的长度
像我只取2位ASCII的长度,我就用这个,取出来就直接是ushort类型的数据了.
}
for(int i = 0; i < 1024; i++)
{
for(int j = 0; j < 64; j++)
{
b[i * 64 + j] = (byte)j;
}
}
string s = BitConverter.ToString(b);
s = s.Replace("-","");
http://blog.joycode.com/zhanbos/posts/27008.aspx#FeedBack
注意第二题的答案大体和test7979(test7979) 一致:)
'0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};public static string ToHexString(byte[] bytes)
{
char[] chars = new char[bytes.Length * 2];
for (int i = 0; i < bytes.Length; i++)
{
int b = bytes[i];
chars[i * 2] = hexDigits[b >> 4];
chars[i * 2 + 1] = hexDigits[b & 0xF];
}
return new string(chars);
}