在非静态类不是静态方法为什么是一个扩展方法?静态、方法、不是、为什么是

由网友(荒年)分享简介:可能重复: extension方法需要类是静态 在.NET中:为什么不能静态方法在非静态类是一个扩展方法?Why can't static method in non-static class be an extension method?推荐答案埃里克利珀可能会权衡与这一个一个很好的答案,但它的要点可能会...

可能重复:   extension方法需要类是静态

在.NET中:

为什么不能静态方法在非静态类是一个扩展方法?

Why can't static method in non-static class be an extension method?

推荐答案

埃里克利珀可能会权衡与这一个一个很好的答案,但它的要点可能会是:

Eric Lippert will probably weigh in with a really good answer on this one, but the gist of it will probably be:

我们决定这将是对程序员和编译器更加容易,如果我们限制的地方,你必须寻找扩展方法的数量。

We decided it would be easier on both programmers and the compiler if we limit the number of places that you have to look for extension methods.

这政策往往迫使​​用户把他们所有的扩展方法进入被指定用于此目的的几个具体类别。

This policy tends to force users to put all of their extension methods into a few specific classes that are designated for this purpose.

阅读全文

相关推荐

最新文章