本文整理匯總了VB.NET中System.Guid.TryParse方法的典型用法代碼示例。如果您正苦於以下問題:VB.NET Guid.TryParse方法的具體用法?VB.NET Guid.TryParse怎麽用?VB.NET Guid.TryParse使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Guid
的用法示例。
在下文中一共展示了Guid.TryParse方法的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.
Dim newGuid As Guid
For Each stringGuid In stringGuids
If Guid.TryParse(stringGuid, newGuid) Then
Console.WriteLine("Converted {0} to a Guid", stringGuid)
Else
Console.WriteLine("Unable to convert {0} to a Guid",
stringGuid)
End If
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