This article mainly introduces the ASP. System.Guid ToString Five format, the need for friends can refer to the following
Reference: Https://msdn.microsoft.com/en-us/library/97af8hh4.aspx
Test code:
Using system;using system.collections.generic;using system.linq;using system.text;namespace GuidToString{ class Program { static void Main (string[] args) { Console.WriteLine ("--" + System.Guid.NewGuid (). ToString ()); Console.WriteLine ("N-->" + System.Guid.NewGuid (). ToString ("N")); Console.WriteLine ("D-->" + System.Guid.NewGuid (). ToString ("D")); Console.WriteLine ("B-->" + System.Guid.NewGuid (). ToString ("B")); Console.WriteLine ("P-->" + System.Guid.NewGuid (). ToString ("P")); Console.WriteLine ("X-->" + System.Guid.NewGuid (). ToString ("X")); Console.readkey ();}}}
Test results:
Note: You can use only N, D, B, P, X (case-insensitive) NULL, and other letters will cause an exception
The format string can only be "D", "D", "N", "n", "P", "P", "B", "B", "X", or "X".
Exception Condition:
The following are normal:
Using system;using system.collections.generic;using system.linq;using system.text;namespace GuidToString{class program {static void Main (string[] args) {Console.WriteLine ("--" + System.Guid.NewGuid (). ToString ()); Console.WriteLine ("--" + System.Guid.NewGuid (). ToString ("")); Console.WriteLine ("N-->" + System.Guid.NewGuid (). ToString ("N")); Console.WriteLine ("N-->" + System.Guid.NewGuid (). ToString ("n")); Console.WriteLine ("D-->" + System.Guid.NewGuid (). ToString ("D")); Console.WriteLine ("D-->" + System.Guid.NewGuid (). ToString ("D")); Console.WriteLine ("B-->" + System.Guid.NewGuid (). ToString ("B")); Console.WriteLine ("B-->" + System.Guid.NewGuid (). ToString ("B")); Console.WriteLine ("P-->" + System.Guid.NewGuid (). ToString ("P")); Console.WriteLine ("P-->" + System.Guid.NewGuid (). ToString ("P")); Console.WriteLine ("X-->" + System.Guid.NewGuid (). ToString ("X")); Console.WriteLine ("X-->" + SyStem. Guid.NewGuid (). ToString ("x")); Console.readkey (); } }}
Guid.NewGuid (). Several formats for ToString ()
1, Guid.NewGuid (). The result of ToString ("N") is:
38bddf48f43c48588e0d78761eaa1ce6
2, Guid.NewGuid (). The result of ToString ("D") is:
57d99d89-caab-482a-a0e9-a0a803eed3ba
3, Guid.NewGuid (). The result of ToString ("B") is:
{09f140d5-af72-44ba-a763-c861304b46f8}
4, Guid.NewGuid (). The result of ToString ("P") is:
(778406C2-EFFF-4262-AB03-70A77D09C2B5)