本文整理汇总了VB.NET中System.Guid.ParseExact方法的典型用法代码示例。如果您正苦于以下问题:VB.NET Guid.ParseExact方法的具体用法?VB.NET Guid.ParseExact怎么用?VB.NET Guid.ParseExact使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Guid
的用法示例。
在下文中一共展示了Guid.ParseExact方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: Example
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
输出:
Bad Format: 3351d3f0006747089ff928b5179b2051 Bad Format: 3351d3f0-0067-4708-9ff9-28b5179b2051 Successfully parsed {3351d3f0-0067-4708-9ff9-28b5179b2051} Bad Format: (3351d3f0-0067-4708-9ff9-28b5179b2051) Bad Format: {0x3351d3f0,0x0067,0x4708,{0x9f,0xf9,0x28,0xb5,0x17,0x9b,0x20,0x51}}