110,535
社区成员
发帖
与我相关
我的任务
分享
static void Main(string[] args)
{
var s = "ac";
var t = "adcdef";
Console.WriteLine(string.Compare(s, t) > 0 ? "大于" : "小于");
Console.WriteLine(DictionariesCompare(s, t) ? "大于" : "小于");
Console.ReadKey();
}
static bool DictionariesCompare(string s, string t)
{
for (var i = 0; i < Math.Min(s.Length, t.Length); i++)
{
if (s[i] != t[i]) return s[i] < t[i];
}
return s.Length > t.Length;
}