Created
March 2, 2018 14:19
-
-
Save JohnLBevan/b140d26cbe893a6f3c25153ce7d8bb3f to your computer and use it in GitHub Desktop.
Quick Reference :: GUID Formatting in .Net
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
| //case of the format makes no difference (e.g. D and d give the same output / have no impact on the output string's case as suspected) | |
| Guid guid = Guid.NewGuid(); | |
| Console.WriteLine(guid); //same as D/d | |
| //75dad478-98cf-4a5f-afc4-ad172747db0b | |
| Console.WriteLine(guid.ToString("D")); //digits and hyphens | |
| //75dad478-98cf-4a5f-afc4-ad172747db0b | |
| Console.WriteLine(guid.ToString("d")); //digits and hyphens | |
| //75dad478-98cf-4a5f-afc4-ad172747db0b | |
| Console.WriteLine(guid.ToString("N")); //just digits | |
| //75dad47898cf4a5fafc4ad172747db0b | |
| Console.WriteLine(guid.ToString("n")); //just digits | |
| //75dad47898cf4a5fafc4ad172747db0b | |
| Console.WriteLine(guid.ToString("P")); //() | |
| //(75dad478-98cf-4a5f-afc4-ad172747db0b) | |
| Console.WriteLine(guid.ToString("p")); //() | |
| //(75dad478-98cf-4a5f-afc4-ad172747db0b) | |
| Console.WriteLine(guid.ToString("B")); //{} | |
| //{75dad478-98cf-4a5f-afc4-ad172747db0b} | |
| Console.WriteLine(guid.ToString("b")); //{} | |
| //{75dad478-98cf-4a5f-afc4-ad172747db0b} | |
| Console.WriteLine(guid.ToString("X")); //btyes | |
| //{0x75dad478,0x98cf,0x4a5f,{0xaf,0xc4,0xad,0x17,0x27,0x47,0xdb,0x0b}} | |
| Console.WriteLine(guid.ToString("x")); //btyes | |
| //{0x75dad478,0x98cf,0x4a5f,{0xaf,0xc4,0xad,0x17,0x27,0x47,0xdb,0x0b}} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment