作者:VB.NET开发
项目:Syste
Module Example
Public Sub Main()
Dim mainGuid As Guid = Guid.Parse("01e75c83-c6f5-4192-b57e-7427cec5560d")
Dim guid2 As New Guid(&h01e75c83,
BitConverter.ToInt16(new Byte() { &hf5, &hc6 }, 0),
&h4192,
new Byte() { &hb5, &h7e, &h74, &h27, &hce, &hc5, &h56, &h0c} )
Dim guid3 As Guid = Guid.Parse("01e75c84-c6f5-4192-b57e-7427cec5560d")
Console.WriteLine("{0} {1:F} {2}", mainGuid,
CType(mainGuid.CompareTo(guid2), Comparison), guid2)
Console.WriteLine("{0} {1:F} {2}", mainGuid,
CType(mainGuid.CompareTo(guid3), Comparison), guid3)
End Sub
Private Enum Comparison As Integer
LessThan = -1
Equals = 0
GreaterThan = 1
End Enum
End Module
作者:VB.NET开发
项目:Syste
' 导入命名空间
Imports System.Runtime.InteropServices
<Guid("936DA01F-9ABD-4d9d-80C7-02AF85C822A8")>
Module Example
Public Sub Main()
Dim guidAttr As GuidAttribute = CType(Attribute.GetCustomAttribute(GetType(Example),
GetType(GuidAttribute)), GuidAttribute)
Dim guidValue As Guid = Guid.Parse(guidAttr.Value)
Dim values() As Object = { Nothing, 16,
Guid.Parse("01e75c83-c6f5-4192-b57e-7427cec5560d"),
guidValue }
For Each value In values
Try
Console.WriteLine("{0} and {1}: {2}", guidValue,
If(value Is Nothing, "null", value),
guidValue.CompareTo(value))
Catch e As ArgumentException
Console.WriteLine("Cannot compare {0} and {1}", guidValue,
If(value Is Nothing, "null", value))
End Try
Next
End Sub
End Module