public virtual string GuidToForm1(Guid value)
{
byte[] GuidBytes = value.ToByteArray();
StringBuilder ResultingStr = new StringBuilder(80);
// First 4 bytes
int i = 0;
int Number = 0;
for(i = 0; i < 4; ++i)
{
int CurrentByte = GuidBytes[i];
Number += CurrentByte << (8 * i);
}
UInt32 FourBytes = (UInt32)Number;
ResultingStr.AppendFormat(CultureInfo.InvariantCulture, "0x{0}", FourBytes.ToString("X", CultureInfo.InvariantCulture));
// 2 chunks of 2 bytes
for(int j = 0; j < 2; ++j)
{
Number = 0;
for(int k = 0; k < 2; ++k)
{
int CurrentByte = GuidBytes[i++];
Number += CurrentByte << (8 * k);
}
UInt16 TwoBytes = (UInt16)Number;
ResultingStr.AppendFormat(CultureInfo.InvariantCulture, ", 0x{0}", TwoBytes.ToString("X", CultureInfo.InvariantCulture));
}
// 8 chunks of 1 bytes
for(int j = 0; j < 8; ++j)
{
ResultingStr.AppendFormat(CultureInfo.InvariantCulture, ", 0x{0}", GuidBytes[i++].ToString("X", CultureInfo.InvariantCulture));
}
return ResultingStr.ToString();
}