Guid.ToString Method (String)

July 28, 2014

Returns a String representation of the value of this Guid instance, according to the provided format specifier.

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

public string ToString(
	string format
)

Parameters

format
Type: System.String
A single format specifier that indicates how to format the value of this Guid. The format parameter can be "N", "D", "B", or "P". If format is null or the empty string (""), "D" is used.

Return Value

Type: System.String
The value of this Guid, represented as a series of lowercase hexadecimal digits in the specified format.

ExceptionCondition
FormatException

The value of format is not null, the empty string (""), "N", "D", "B", or "P".

The format parameter can contain the following format specifiers. In the table that follows, all digits in the return value are hexadecimal. Each character 'x' represents a hexadecimal digit; each hyphen ('-'), bracket ('{', '}'), and parenthesis ('(', ')') appears as shown.

Specifier

Format of Return Value

N

32 digits:

xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

D

32 digits separated by hyphens:

xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

B

32 digits separated by hyphens, enclosed in brackets:

{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx}

P

32 digits separated by hyphens, enclosed in parentheses:

(xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx)

Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2014 Microsoft