This documentation is archived and is not being maintained.

Guid.ToString Method (String, IFormatProvider)

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

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

Public Function ToString ( _
	format As String, _
	provider As IFormatProvider _
) As String


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", "P", or "X". If format is Nothing or an empty string (""), "D" is used.
Type: System.IFormatProvider
(Reserved) An object 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 Nothing, an empty string (""), "N", "D", "B", "P", or "X".

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.

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


Format of return value


32 digits:



32 digits separated by hyphens:



32 digits separated by hyphens, enclosed in braces:



32 digits separated by hyphens, enclosed in parentheses:



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


.NET Framework

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

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

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