Export (0) Print
Expand All

Guid.IFormattable.ToString Method

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

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

string IFormattable.ToString(
	string format,
	IFormatProvider provider
)

Parameters

format
Type: System.String

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

provider
Type: System.IFormatProvider

(Reserved) An object that supplies culture-specific formatting information.

Return Value

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

Implements

IFormattable.ToString(String, IFormatProvider)

ExceptionCondition
FormatException

The value of format is not null, an empty string (""), or one of the following single format specifiers:"N", "D", "B", "P", or "X".

This member is an explicit interface implementation. It can be used only when the Guid instance is cast to an IFormattable interface object.

The provider parameter is reserved for future use and does not contribute to the execution of this method. This parameter can be a null reference.

The following table shows the supported format specifiers for the format parameter. "0" represents a digit; hyphens ("-"), braces ("{", "}"), and parentheses ("(", ")") appear as shown.

Specifier

Format of return value

N

32 digits:

00000000000000000000000000000000

D

32 digits separated by hyphens:

00000000-0000-0000-0000-000000000000

B

32 digits separated by hyphens, enclosed in braces:

{00000000-0000-0000-0000-000000000000}

P

32 digits separated by hyphens, enclosed in parentheses:

(00000000-0000-0000-0000-000000000000)

X

Four hexadecimal values enclosed in braces, where the fourth value is a subset of eight hexadecimal values that is also enclosed in braces:

{0x00000000,0x0000,0x0000,{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}}

.NET Framework

Supported in: 4.6

Portable Class Library

Supported in: Portable Class Library

.NET for Windows Store apps

Supported in: Windows 8
Show:
© 2014 Microsoft