Visual Studio 2012 不让我调试接口的实现

Visual Studio 2012 won't let me debug Implementation of Interface

我正在研究 LINQ 中的一些查询并想了解它的实现,所以我想调试它但是当我尝试这样做时 Visual Studio 没有进入接口的实现不知道为什么。我正在使用 Visual Studio Community 2015。这是我的代码

class Client
    {
        static void Main(string[] args)
        {
            string[] words = { "aPPLE", "AbAcUs", "bRaNcH", "BlUeBeRrY", "ClOvEr", "cHeRry" };
            var result = words.OrderBy(a => a, new CaseInsensitiveComparer());
            Console.Read();
        }
    }
    public class CaseInsensitiveComparer : IComparer<string>
    {
        public int Compare(string x, string y)
        {
            Console.WriteLine("x is " + x + " & y is " + y+" the value is "+ string.Compare(x, y, StringComparison.OrdinalIgnoreCase));
            return string.Compare(x, y, StringComparison.OrdinalIgnoreCase);
        }
    }

最可悲的是我也无法在控制台中打印任何内容 window

Console.WriteLine("x is " + x + " & y is " + y+" the value is "+ string.Compare(x, y, StringComparison.OrdinalIgnoreCase));

我知道有很多关于此的重复问题,但我尝试了所有方法并且 none 对我有用。

  1. 我尝试清洗溶液
  2. 删除 Obj 和 Bin 文件夹
  3. 关闭解决方案并再次打开并重建它 对我没有任何作用。

更新 1

我已将调试器置于 IComparer 的实现中

OrderBy returns 和 IEnumrable 要设置 Linq 查询,请在 OrderBy 子句

之后添加 ToList()
 var result = words.OrderBy(a => a, new CaseInsensitiveComparer()).ToList();

你的 .OrderBy() 调用只会在你使用它的结果时被评估(很多 linq 方法就是这种情况)。由于您没有使用结果,因此代码实际上不是 运行ning.

在末尾加上一个.ToList(),它就会运行:

var result = words.OrderBy(a => a, new CaseInsensitiveComparer()).ToList();

您可能无法进入 .OrderBy() 调用,但您可以在比较器实现中放置一个断点。