1.词汇
- Features related to the type system 和类型系统有关的特性
2.例句
-
Extension methods are also there for the sake of LINQ but can be useful outside it.
扩展方法也是为了LINQ而存在的,但在LINQ之外也可以用。
-
Think of all the times you’ve wished that a framework type had a certain method, and you’ve had to write a static utility method to implement it.
想想你一直希望一个框架类型有一个特定的方法,而你必须编写一个静态实用程序方法来实现它。
-
For instance, to create a new string by reversing an existing one, you might write a static StringUtil.Reverse method.
例如,要通过反转现有字符串来创建新字符串,x需要编写一个静态StringUtil.Reverse方法。
-
Well, the extension method feature effectively lets you call that static method as if it existed on the string type itself, so you could write
现在,扩展方法特性可以有效地让您调用静态方法,就好像它本身就是字符串类型的方法一样,所以您可以这样写
string x = "dlrow olleH".Reverse();
-
Extension methods also let you appear to add methods with implementations to interfaces, and LINQ relies on this heavily, allowing calls to all kinds of methods on IEnumerable<T> that have never previously existed.
扩展方法还允许您将带有实现的方法添加到接口中,而LINQ非常依赖这个特性,允许对以前从未存在的IEnumerable<T>上的所有类型的方法进行调用。