Posts tagged Byte array to Integer (vice versa)
Byte array to Integer (vice versa)
Feb 26th
1: public static int BytesToInt(byte[] bytes) 2: { 3: return int.Parse(BytesToString(bytes).Trim()); 4: } 5: 6: public static string BytesToString(byte[] bytes) 7: { 8: ASCIIEncoding enc = new System.Text.ASCIIEncoding(); 9: return enc.GetString(bytes); 10: } 1: public static byte[] IntToBytes(int value) 2: { 3: ASCIIEncoding enc = new System.Text.ASCIIEncoding(); 4: return enc.GetBytes(value.ToString()); 5: } Code Snippet /// [...]