Converts the string representation of a GUID to the equivalent Guid structure. : GUID « Development « VB.Net






Converts the string representation of a GUID to the equivalent Guid structure.

 

Imports System

Class Sample
   Public Shared  Sub Main()
        Dim GStart As Guid = Guid.NewGuid()
        Dim guidB As String = GStart.ToString("B")
    
        Dim GCurrent As Guid = Guid.Parse(guidB)
        Dim guidX As String = GCurrent.ToString("X")
    
        If Guid.TryParse(guidX, GCurrent) Then
            Console.WriteLine(GCurrent.ToString("X"))
        Else
            Console.WriteLine("Last parse operation unsuccessful.")
        End If
    
        If Guid.TryParseExact(guidX, "X", GCurrent) Then
            Console.WriteLine(GCurrent.ToString("X"))
        Else
            Console.WriteLine("Last parse operation unsuccessful.")
        End If
    End Sub
End Class 'Sample

   
  








Related examples in the same category

1.GUIDs
2.Generic and nongeneric versions of the CompareTo method for Guid value
3.Guid.NewGuid Method creates a new instance of the Guid class.