Skip to content

Instantly share code, notes, and snippets.

@jrgcubano
Created April 17, 2015 14:41
Show Gist options
  • Save jrgcubano/37ad50d74c4105b9b41e to your computer and use it in GitHub Desktop.
Save jrgcubano/37ad50d74c4105b9b41e to your computer and use it in GitHub Desktop.
Int to Guid and Guid to Int
public static Guid Int2Guid(int value)
{
byte[] 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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment