Guid.Parse Method (String)


Converts the string representation of a GUID to the equivalent Guid structure.

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

static member Parse : 
        input:string -> Guid


Type: System.String

The string to convert.

Return Value

Type: System.Guid

A structure that contains the value that was parsed.

Exception Condition

input is null.


input is not in a recognized format.

The Parse method trims any leading or trailing white space from input and converts the string representation of a GUID to a Guid value. This method can convert strings in any of the five formats produced by the ToString(String) and ToString(String, IFormatProvider) methods, as shown in the following table.





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


The method throws a FormatException if it is unable to successfully parse the string. Here are some of the reasons why this might occur include:

  • input contains characters that are not part of the hexadecimal character set.

  • input has too many or too few numeric characters.

  • input has too many or too few of the non-numeric characters appropriate for a particular format.

  • input is not in one of the formats recognized by the ToString method and listed in the previous table.

Use the TryParse method to catch any unsuccessful parse operations without having to handle an exception.

The following example creates a new GUID, converts it to three separate string representations by calling the ToString(String) method with the "B", "D", and "X" format specifiers, and then calls the Parse method to convert the strings back to Guid values.

No code example is currently available or this language may not be supported.

Universal Windows Platform
Available since 8
.NET Framework
Available since 4.0
Portable Class Library
Supported in: portable .NET platforms
Available since 4.0
Windows Phone Silverlight
Available since 7.1
Windows Phone
Available since 8.1
Return to top