自定义扩展方法 Extension

我在这里定义了一个List泛型的扩展方法

public static List<string> GetExten(this List<string> obj)
{
  return new List<string> { };
}

那么我在使用List泛型的时候就可以点出来这个扩展方法

new List<string>().GetExten();

关键是在于 this 关键字,它指定了什么类型,那这个方法就是这个类型的扩展方法

原文地址:https://www.cnblogs.com/opts/p/7885127.html