作者:VB.NET开发
项目:Syste
Module Example
Public Sub Main()
' Define an array of all format specifiers.
Dim formats() As String = { "N", "D", "B", "P", "X" }
Dim guid As Guid = Guid.NewGuid()
' Create an array of valid Guid string representations.
Dim stringGuids(formats.Length - 1) As String
For ctr As Integer = 0 To formats.Length - 1
stringGuids(ctr) = guid.ToString(formats(ctr))
Next
' Try to parse the strings in the array using the "B" format specifier.
For Each stringGuid In stringGuids
Dim newGuid As Guid
If Guid.TryParseExact(stringGuid, "B", newGuid) Then
Console.WriteLine("Successfully parsed {0}", stringGuid)
Else
Console.WriteLine("Unable to parse '{0}'", stringGuid)
End If
Next
End Sub
End Module