本文整理汇总了VB.NET中System.Guid.CompareTo方法的典型用法代码示例。如果您正苦于以下问题:VB.NET Guid.CompareTo方法的具体用法?VB.NET Guid.CompareTo怎么用?VB.NET Guid.CompareTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Guid 的用法示例。
在下文中一共展示了Guid.CompareTo方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。
示例1: Example
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
开发者ID:VB.NET开发者,项目名称:System,代码行数:21,代码来源:Guid.CompareTo 输出:
01e75c83-c6f5-4192-b57e-7427cec5560d GreaterThan 01e75c83-c6f5-4192-b57e-7427cec5560c
01e75c83-c6f5-4192-b57e-7427cec5560d LessThan 01e75c84-c6f5-4192-b57e-7427cec5560d
示例2: Example
' 导入命名空间
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
开发者ID:VB.NET开发者,项目名称:System,代码行数:24,代码来源:Guid.CompareTo 输出:
936da01f-9abd-4d9d-80c7-02af85c822a8 and null: 1
Cannot compare 936da01f-9abd-4d9d-80c7-02af85c822a8 and 16
936da01f-9abd-4d9d-80c7-02af85c822a8 and 01e75c83-c6f5-4192-b57e-7427cec5560d: 1
936da01f-9abd-4d9d-80c7-02af85c822a8 and 936da01f-9abd-4d9d-80c7-02af85c822a8: 0
注:本文中的System.Guid.CompareTo方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论