ASP. System.Guid ToString Five formats

Source: Internet
Author: User
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)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.