惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
T
Threatpost
Latest news
Latest news
N
News | PayPal Newsroom
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Help Net Security
Help Net Security
D
Darknet – Hacking Tools, Hacker News & Cyber Security
AI
AI
Simon Willison's Weblog
Simon Willison's Weblog
TaoSecurity Blog
TaoSecurity Blog
The Last Watchdog
The Last Watchdog
L
LINUX DO - 热门话题
Google DeepMind News
Google DeepMind News
T
Threat Research - Cisco Blogs
O
OpenAI News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
The Exploit Database - CXSecurity.com
NISL@THU
NISL@THU
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Securelist
小众软件
小众软件
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Martin Fowler
Martin Fowler
S
SegmentFault 最新的问题
Cisco Talos Blog
Cisco Talos Blog
云风的 BLOG
云风的 BLOG
AWS News Blog
AWS News Blog
GbyAI
GbyAI
N
News and Events Feed by Topic
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
美团技术团队
Engineering at Meta
Engineering at Meta
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
S
Schneier on Security
博客园 - 聂微东
V2EX - 技术
V2EX - 技术
T
Troy Hunt's Blog
SecWiki News
SecWiki News
S
Secure Thoughts
B
Blog RSS Feed
Hugging Face - Blog
Hugging Face - Blog
WordPress大学
WordPress大学
腾讯CDC
H
Heimdal Security Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
Apple Machine Learning Research
Apple Machine Learning Research
月光博客
月光博客
www.infosecurity-magazine.com
www.infosecurity-magazine.com
P
Privacy International News Feed

博客园 - 深山老林

测试Varnish缓存服务器与IIS连接数 谈谈持续集成 亲测SQLServer的最大连接数 读书笔记:Oracle锁定策略的总结 jQuery formValidator不支持新版手机的解决办法 TFS Workspace错误解决办法 Mindjet.MindManager.v9.0“参数错误”解决办法 Entityframework提供的处理并发冲突方式 ASP.NET MVC2中返回Json异常的解决办法 Visual studio 配置文件下载 WF之基本概念 数据库访问的性能问题与瓶颈问题 SQLServer中批量插入数据方式的性能对比 再次探扩展-对xVal进行扩展解决验证不同步的问题 微软并行编程类库Parallel Extensions介绍 更改Outlook数据文件的路径 谈谈c#中的static 再次探讨企业级开发中的Try......Catch性能问题 在企业级开发中使用Try...Catch...会影响效率吗?
c#3.0提供的扩展方法
深山老林 · 2010-07-18 · via 博客园 - 深山老林

在c#3.0之前,想要为内置的类型添加一个方法显然是不可能的。但是,c#3.0提供的扩展方法可以解决这个问题。具体代码如下:

    public static class ExtendedClass
{
public static string ToKevin(this string str)
{
return "hello,kevin";
}
}
public class Program
{
static void Main(string[] args)
{
DateTime dt = DateTime.Now;
string str1 = dt.ToShortDateString().ToKevin();
Console.WriteLine(str1);
}
}