Convert Int to Guid

Here is a simple way to do it:

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

You can change where the copy will happen (vary the index from 0 to 12). It really depends on how you want to define this unusual “int to Guid” conversion.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)