C# Guid ToString(String)
Description
Guid ToString(String)
returns a string representation
of the value of this Guid instance, according to the provided format specifier.
Syntax
Guid.ToString(String)
has the following syntax.
public string ToString(
string format
)
Parameters
Guid.ToString(String)
has the following parameters.
format
- A single format specifier that indicates how to format the value of this Guid. The format parameter can be "N", "D", "B", "P", or "X". If format is null or an empty string (""), "D" is used.
Returns
Guid.ToString(String)
method returns The value of this Guid, represented as a series of lowercase hexadecimal
digits in the specified format.
Example
using System;// w w w. ja va 2s. c om
public class Example
{
public static void Main()
{
Guid guid = Guid.NewGuid();
Console.WriteLine("Guid: {0}", guid.ToString("N"));
Console.WriteLine("Guid: {0}", guid.ToString("D"));
Console.WriteLine("Guid: {0}", guid.ToString("B"));
Console.WriteLine("Guid: {0}", guid.ToString("P"));
Console.WriteLine("Guid: {0}", guid.ToString("X"));
}
}
The code above generates the following result.