Conversion of byte array containing hex values to decimal values

前端 未结 5 2074
一生所求
一生所求 2021-01-01 04:17

I am making application in c#.Here i want to convert a byte array containing hex values to decimal values.Suppose i have one byte array as

array[0]=0X4E;
ar         


        
5条回答
  •  清酒与你
    2021-01-01 04:52

    The BitConverter.ToInt32 method is a good way to do this

    if (BitConverter.IsLittleEndian)
        Array.Reverse(array); //need the bytes in the reverse order
    int value = BitConverter.ToInt32(array, 0);
    

提交回复
热议问题