首页 > 其他 > 详细

扩展方法 1 简单的string扩展方法

时间:2016-08-27 23:13:16      阅读:113      评论:0      收藏:0      [点我收藏+]
这里是关于 String的简单扩展方法 (静态类 静态方法 this 类型 这里是string)
技术分享
 1  static class Program
 2     {
 3         static void Main(string[] args)
 4         {
 5 
 6             Test2();
 7             Console.ReadKey();
 8         }
 9 
10         public static string FormatWith(this string format, params object[] args)
11         {
12             return string.Format(format, args);
13         }
14         public static void Test2()
15         {
16             string today = "今天是:{0:yyyy年MM月dd日 ddd}";
17             //这里调用了扩展方法
18             Console.WriteLine(today .FormatWith(DateTime.Today));
19         }
20     }
View Code

 

扩展方法 1 简单的string扩展方法

原文:http://www.cnblogs.com/nanxiaoxiang/p/5813928.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!