Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
ToString Method (String, IFormatProvider)
Collapse the table of content
Expand the table of content

Guid.ToString Method (String, IFormatProvider)

Updated: January 2010

Returns a String representation of the value of this instance of the Guid class, according to the provided format specifier and culture-specific format information.

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

public string ToString(
	string format,
	IFormatProvider provider


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.

Type: System.IFormatProvider

(Reserved) An IFormatProvider reference that supplies culture-specific formatting services.

Return Value

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


IFormattable.ToString(String, IFormatProvider)


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.


Format of Return Value


32 digits:



32 digits separated by hyphens:



32 digits separated by hyphens, enclosed in brackets:



32 digits separated by hyphens, enclosed in parentheses:


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

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 3.5, 2.0, 1.0

XNA Framework

Supported in: 3.0, 2.0, 1.0




January 2010

Updated return value description.

Customer feedback.

Community Additions

© 2015 Microsoft