To convert one simple type (for example int), to another simple type (for example float or string) it is suggested to use .NET class BitConverter.
C# code sample:
static void Main()
{
int intData = 0x01020304;
byte[] bytesData = BitConverter. GetBytes(intData);
float floatData = BitConverter.ToSingle(bytesData, 0);
string stringData = BitConverter.ToString(bytesData);
}
Result values (from VS Locals Window):
Reference:
No comments:
Post a Comment