本文整理汇总了VB.NET中System.String.CompareOrdinal方法的典型用法代码示例。如果您正苦于以下问题:VB.NET String.CompareOrdinal方法的具体用法?VB.NET String.CompareOrdinal怎么用?VB.NET String.CompareOrdinal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.String 的用法示例。
在下文中一共展示了String.CompareOrdinal方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的VB.NET代码示例。
示例1: Test
' 导入命名空间
Imports System.Globalization
Class Test
Public Shared Sub Main(args() As [String])
Dim strLow As [String] = "abc"
Dim strCap As [String] = "ABC"
Dim result As [String] = "equal to "
Dim x As Integer = 0
Dim pos As Integer = 1
' The Unicode codepoint for 'b' is greater than the codepoint for 'B'.
x = [String].CompareOrdinal(strLow, pos, strCap, pos, 1)
If x < 0 Then
result = "less than"
End If
If x > 0 Then
result = "greater than"
End If
' In U.S. English culture, 'b' is linguistically less than 'B'.
Console.WriteLine("CompareOrdinal(""{0}"".Chars({2}), ""{1}"".Chars({2})):", strLow, strCap, pos)
Console.WriteLine(" '{0}' is {1} '{2}'", strLow.Chars(pos), result, strCap.Chars(pos))
x = [String].Compare(strLow, pos, strCap, pos, 1, False, New CultureInfo("en-US"))
If x < 0 Then
result = "less than"
ElseIf x > 0 Then
result = "greater than"
End If
Console.WriteLine("Compare(""{0}"".Chars({2}), ""{1}"".Chars({2})):", strLow, strCap, pos)
Console.WriteLine(" '{0}' is {1} '{2}'", strLow.Chars(pos), result, strCap.Chars(pos))
End Sub
End Class
开发者ID:VB.NET开发者,项目名称:System,代码行数:36,代码来源:String.CompareOrdinal
示例2: Sample
' Sample for String.CompareOrdinal(String, String)
Class Sample
Public Shared Sub Main()
Dim str1 As [String] = "ABCD"
Dim str2 As [String] = "abcd"
Dim str As [String]
Dim result As Integer
Console.WriteLine()
Console.WriteLine("Compare the numeric values of the corresponding Char objects in each string.")
Console.WriteLine("str1 = '{0}', str2 = '{1}'", str1, str2)
result = [String].CompareOrdinal(str1, str2)
str = IIf(result < 0, "less than", IIf(result > 0, "greater than", "equal to"))
Console.Write("String '{0}' is ", str1)
Console.Write("{0} ", str)
Console.WriteLine("String '{0}'.", str2)
End Sub
End Class
开发者ID:VB.NET开发者,项目名称:System,代码行数:18,代码来源:String.CompareOrdinal 输出:
Compare the numeric values of the corresponding Char objects in each string.
str1 = 'ABCD', str2 = 'abcd'
String 'ABCD' is less than String 'abcd'.
注:本文中的System.String.CompareOrdinal方法示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论