本文整理汇总了VB.NET中System.Globalization.CompareInfo.GetCompareInfo方法的典型用法代码示例。如果您正苦于以下问题:VB.NET CompareInfo.GetCompareInfo方法的具体用法?VB.NET CompareInfo.GetCompareInfo怎么用?VB.NET CompareInfo.GetCompareInfo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Globalization.CompareInfo
的用法示例。
在下文中一共展示了CompareInfo.GetCompareInfo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的VB.NET代码示例。
示例1: SamplesCompareInfo
' The following code example compares two strings using the different CompareInfo instances:
' a CompareInfo instance associated with the "Spanish - Spain" culture with international sort,
' a CompareInfo instance associated with the "Spanish - Spain" culture with traditional sort, and
' a CompareInfo instance associated with the InvariantCulture.
Imports System.Globalization
Public Class SamplesCompareInfo
Public Shared Sub Main()
' Defines the strings to compare.
Dim myStr1 As [String] = "calle"
Dim myStr2 As [String] = "calor"
' Uses GetCompareInfo to create the CompareInfo that uses the "es-ES" culture with international sort.
Dim myCompIntl As CompareInfo = CompareInfo.GetCompareInfo("es-ES")
' Uses GetCompareInfo to create the CompareInfo that uses the "es-ES" culture with traditional sort.
Dim myCompTrad As CompareInfo = CompareInfo.GetCompareInfo(&H40A)
' Uses the CompareInfo property of the InvariantCulture.
Dim myCompInva As CompareInfo = CultureInfo.InvariantCulture.CompareInfo
' Compares two strings using myCompIntl.
Console.WriteLine("Comparing ""{0}"" and ""{1}""", myStr1, myStr2)
Console.WriteLine(" With myCompIntl.Compare: {0}", myCompIntl.Compare(myStr1, myStr2))
Console.WriteLine(" With myCompTrad.Compare: {0}", myCompTrad.Compare(myStr1, myStr2))
Console.WriteLine(" With myCompInva.Compare: {0}", myCompInva.Compare(myStr1, myStr2))
End Sub
End Class
输出:
Comparing "calle" and "calor" With myCompIntl.Compare: -1 With myCompTrad.Compare: 1 With myCompInva.Compare: -1