【C#】扩展方法的应用
2017-05-21 13:37
295 查看
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml.Linq; namespace ConsoleApplication27 { class Program { static void Main(string[] args) { int str1 = 200; var flag = str1.IsEmail(); Console.WriteLine(flag); Console.ReadLine(); } } public static class ExtensionMethods { public static bool IsEmail( this int str) { return true; } } }
扩展方法使您能够向现有类型“添加”方法,而无需创建新的派生类型、重新编译或以其他方式修改原始类型。
参考链接:
http://www.cnblogs.com/suger/archive/2012/05/13/2498248.html
相关文章推荐
- C#的扩展方法应用
- C# 扩展方法应用一:中文处理
- C# 扩展方法实际应用整理
- C# Note21: 扩展方法(Extension Method)及其应用
- C# -- 扩展方法的应用(Extension Methods)
- 在MVC中My97date应用C#扩展方法
- C# 扩展方法应用三:字符串处理
- c#扩展方法奇思妙用高级篇三:Enumerable.Cast<T>应用
- C# -- 扩展方法的应用(Extension Methods)
- C#基础---扩展方法的应用
- (转)C# -- 扩展方法的应用(Extension Methods)
- C# 扩展方法在NXOPEN中的应用(2)
- C#扩展方法应用之 try catch finally 封装
- C# 扩展方法应用二:文件操作
- c# 扩展方法奇思妙用高级篇三:Enumerable.Cast<T> 应用
- C#扩展方法的应用
- c# 扩展方法奇思妙用高级篇三:Enumerable.Cast<T> 应用
- C#定义扩展类的应用及方法
- Linq的那些事——从Linq扩展方法回顾C#语言基础
- C# 3.0新特性初步研究 Part2:使用扩展方法_C#教程