Created
April 17, 2015 14:41
-
-
Save jrgcubano/37ad50d74c4105b9b41e to your computer and use it in GitHub Desktop.
Int to Guid and Guid to Int
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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