Поделиться через


Guid.ToString Method (String, IFormatProvider)

Microsoft Silverlight will reach end of support after October 2021. Learn more.

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)

Syntax

'Declaration
Public Function ToString ( _
    format As String, _
    provider As IFormatProvider _
) As String
public string ToString(
    string format,
    IFormatProvider provider
)

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 nulla null reference (Nothing in Visual Basic) or the empty string (""), "D" is used.
  • provider
    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.

Implements

IFormattable.ToString(String, IFormatProvider)

Exceptions

Exception Condition
FormatException

The value of format is not nulla null reference (Nothing in Visual Basic), the empty string (""), "N", "D", "B", or "P".

Remarks

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)

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.

Version Information

Silverlight

Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Xbox 360, Windows Phone OS 7.0

Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.