public static string ByteToString(byte[] InBytes) 
{
string StringOut="";
foreach (byte InByte in InBytes) 
{
StringOut=StringOut + String.Format("{0:X2} ",InByte);
}
return StringOut; 
}

解决方案 »

  1.   

    spraydew(云孤天) 你的方法我以前早就试过了,慢的可以,50K的图片需要半分钟以上,汗!
      

  2.   

    System.Text.StringBuilder kao = new System.Text.StringBuilder(1000);
    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 这样的话速度应该会块很多
      

  3.   

    下面是我在某个网络游戏的配置文件的修改器中的一部分:
    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类型的数据了.
    }
      

  4.   

    换成StringBuilder没多大效果,还是需要很长时间
      

  5.   

    BitConverter.ToString()虽然转出来的格式比较难看,但是应当是飞速吧,希望你不会嫌弃如果要好看,转好后来一下字符串替换
      

  6.   

    byte [] b = new byte[64*1024];
    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("-","");
      

  7.   

    MS的孙展波的可以吗?
    http://blog.joycode.com/zhanbos/posts/27008.aspx#FeedBack
    注意第二题的答案大体和test7979(test7979) 一致:)
      

  8.   

    MSDN上有个示例,我曾经使用过,速度超快,你可以试试 :-)static char[] hexDigits = {
    '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);
    }
      

  9.   

    晕死,还是acewang老大超狠,50K图片就使用了15ms,给分给分!! 来啵一下!
      

  10.   

    考,我说老大,我试过了,读60k的图片我这里也是只有几十ms 啊,哪有你说得这么慢