william-r
11/14/2017 - 5:05 PM

Int to Guid & Guid to Int

public static Guid Int2Guid(int value)
{
    var bytes = new byte[16];
    BitConverter.GetBytes(value).CopyTo(bytes, 0);
    return new Guid(bytes);
}

public static int Guid2Int(Guid value)
{
    byte[] b = value.ToByteArray();
    int bint = BitConverter.ToInt32(b, 0);
    return bint;
}