且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

的&QUOT使用;本"关键字在C#中的静态方法的形式参数

更新时间:2022-05-06 08:21:21

这是一个扩展方法。看到这里的一个explanation.

This is an extension method. See here for an explanation.

扩展方法允许开发人员添加新的方法向公众
  现有的CLR类型的合同,而无需子类,或
  重新编译原始类型。扩展方法帮助交融
  的鸭打字的灵活性支持动态语言中流行
  今天的性能和编译时验证
  强类型语言。

Extension methods allow developers to add new methods to the public contract of an existing CLR type, without having to sub-class it or recompile the original type. Extension Methods help blend the flexibility of "duck typing" support popular within dynamic languages today with the performance and compile-time validation of strongly-typed languages.

扩展方法使各种有用的方案,并帮助
  可能真正强大的LINQ查询框架...

Extension Methods enable a variety of useful scenarios, and help make possible the really powerful LINQ query framework... .

这意味着你可以调用

MyClass myClass = new MyClass();
int i = myClass.Foo();

而不是

MyClass myClass = new MyClass();
int i = Foo(myClass);

这允许流利的接口建设如下所述。