Linq(拓展方法+select())

 

 

拓展方法:

   目的:对于已存在类型的行为进行拓展

    注意事项:

 1:扩展方法必须是一种特殊的静态方法

 2:扩展方法必须是在静态类中

 3: 扩展方法的优先级低于同名类的方法

  4:扩展方法只在特定的命名空间内有效

  5:除非必须不要滥用扩展方法

语法:

   

 public static class ClassA

{

public static void EstraMethod(this  string  s)

{

  //this :指向的类型  ,表面为该类型添加扩展方法

  // string :类型

 // s: 形参

}

}
View Code

 

posted on 2016-09-20 20:37  路上有你F  阅读(509)  评论(0编辑  收藏  举报