Converts the string representation of a GUID to the equivalent Guid structure.
Assembly: mscorlib (in mscorlib.dll)
The method 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 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 method to convert the strings back to Guid values.
Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.