Use byte[] as key in dictionary

前端 未结 7 1614
南旧
南旧 2020-12-28 12:11

I need to use a byte[] as a key in a Dictionary. Since byte[] doesn\'t override the default GetHashCode method, two sepa

7条回答
  •  醉酒成梦
    2020-12-28 12:56

    Could you convert the byte[] to a string and use that as the key?

    Something like:

            ASCIIEncoding enc = new ASCIIEncoding();
            byte[] input;
            string demo = new string(enc.GetChars(input));
            byte[] decode = enc.GetBytes(demo.ToCharArray());
    

提交回复
热议问题