C# 对使用字符串感到困惑。比较?

C# 对使用字符串感到困惑。比较?,c#,string,visual-studio-2013,compareto,C#,String,Visual Studio 2013,Compareto,我使用字符串。比较如下示例 static void Main(string[] args) { int result = String.Compare("A", "a"); Console.Write(result); Console.ReadKey(); } 但是,当运行程序时,结果是1。但我的结果将是-1。 我使用vs 2013。你的期望是错误的。 String.Comparestr1,str2 如果str1大于str2,则结

我使用字符串。比较如下示例

static void Main(string[] args)
    {
        int result = String.Compare("A", "a");
        Console.Write(result);
        Console.ReadKey();
    }
但是,当运行程序时,结果是1。但我的结果将是-1。 我使用vs 2013。

你的期望是错误的。 String.Comparestr1,str2 如果str1大于str2,则结果大于零,并且 如果str1小于str2,则结果小于零,并且
如果str1等于str2,则结果为零。VS2013我打赌hjpotter92是在谈论地区。不管怎样,问题的第一版是A和b,现在是A和A。是的,现在是对的。但当我运行程序时,我的结果将是-1,但结果是1?!为什么?除了阅读重复的问题外,还请仔细阅读从字符串链接的MSDN。为了方便起见,请比较文档。OP知道这一点,并理所当然地期望a大于a。但事实恰恰相反。