C#字节byte数组与bool/int/double/char等
2021-04-25 本文已影响0人
堆石成山
//bool
byte[] boolArray = BitConverter.GetBytes(true);
bool boolValue = BitConverter.ToBoolean(boolArray,0);
//double
byte[] doubleArray = BitConverter.GetBytes(-20.3);
double doubleValue = BitConverter.ToDouble(doubleArray,0);
其余类似。