TryParse(Value: String; Var Result: Guid): Boolean;
Value. The string value that must be converted to the Guid type.
Result. Variable, into which the value in case of successful conversion will be placed.
The TryParse method converts a string value to the Guid type with string correctness validation.
If conversion is successful, the method returns True, and the converted value is placed to the variable specified in the Result parameter.
Sub SampleGuid;
Var
g: Guid;
b: Boolean;
Begin
b := Guid.TryParse("{10101010-1010-1010-1010-101010101010}", g);
Debug.WriteLine(b ? g.ToString : "Not parse");
b := Guid.TryParse("10101010-1010-1010-ABCD-101010101010", g);
Debug.WriteLine(b ? g.ToString : "Not parse");
b := Guid.TryParse("XYZ01010-1010-1010-1010-101010101XYZ", g);
Debug.WriteLine(b ? g.ToString : "Not parse");
End Sub SampleGuid;
On executing the example it will be checked if various string values can be converted to the Guid type. The check and conversion results will be displayed in the development environment console.
See also: