本文整理匯總了VB.NET中System.Guid.Parse方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET Guid.Parse方法的具體用法?VB.NET Guid.Parse怎麽用?VB.NET Guid.Parse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Guid
的用法示例。
在下文中一共展示了Guid.Parse方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的VB.NET代碼示例。
示例1: Example
Module Example
Public Sub Main()
Dim originalGuid As Guid = Guid.NewGuid()
' Create an array of string representations of the GUID.
Dim stringGuids() As String = { originalGuid.ToString("B"),
originalGuid.ToString("D"),
originalGuid.ToString("X") }
' Parse each string representation.
For Each stringGuid In stringGuids
Try
Dim newGuid As Guid = Guid.Parse(stringGuid)
Console.WriteLine("Converted {0} to a Guid", 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
輸出:
Converted {81a130d2-502f-4cf1-a376-63edeb000e9f} to a Guid Converted 81a130d2-502f-4cf1-a376-63edeb000e9f to a Guid Converted {0x81a130d2,0x502f,0x4cf1,{0xa3,0x76,0x63,0xed,0xeb,0x00,0x0e,0x9f}} to a Guid