作者: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
' Parse the strings in the array using the "B" format specifier.
For Each stringGuid In stringGuids
Try
Dim newGuid As Guid = Guid.ParseExact(stringGuid, "B")
Console.WriteLine("Successfully parsed {0}", stringGuid)
Catch e As ArgumentNullException
Console.WriteLine("The string to be parsed is null.")
Catch e As FormatException
Console.WriteLine("Bad Format: {0}", stringGuid)
End Try
Next
End Sub
End Module