【发布时间】:2021-04-07 17:54:09
【问题描述】:
using System;
public class Program
{
public static void Main()
{
string t1, t2;
t1 = "Test";
t2 = "test";
Console.WriteLine(t1.CompareTo(t2)); //prints 1, expected was -1
}
}
所以,它说CompareTo() 应该返回 1 - 如果它大于, -1 如果它小于或 0 如果它等于另一个字符串。在此示例中,我将“测试”与“测试”进行比较。据我了解,在 ASCII 中,'A'
【问题讨论】:
-
比较字符的方法有很多种。也许“序数”比较器为您提供了顺序的 ASCII 定义?
标签: c#