Asp.net System. Guid ToString format,
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: Only N, D, B, P, and X (case-insensitive) are allowed. Exceptions may occur when other letters are used.
The format string can only be "D", "d", "N", "n", "P", "p", "B", "B", "X", or "x ".
Exception:
The following operations 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(); } }}
Several formats of Guid. NewGuid (). ToString ()
1. The result of Guid. NewGuid (). ToString ("N") is:
38bddf48f43c48588e0d78761eaa1ce6
2. The result of Guid. NewGuid (). ToString ("D") is:
57d99d89-caab-482a-a0e9-a0a803eed3ba
3. The result of Guid. NewGuid (). ToString ("B") is:
{09f140d5-af72-44ba-a763-c861304b46f8}
4. The result of Guid. NewGuid (). ToString ("P") is:
(778406c2-efff-4402-ab03-70a77d09c2b5)