【发布时间】:2009-04-24 19:55:25
【问题描述】:
我们开始使用 C# (.NET 3.0),我想知道你们是如何使用扩展方法的?你什么时候使用它们?
另外,如果您还列出使用它们的所有黑暗先决条件,我将不胜感激。
【问题讨论】:
-
请参阅 my answer to another question 了解我使用的指南。
-
扩展方法对于检查某些对象的值也很有用,比如 http cookie。例如 public static bool IsValid(this HttpCookie cookie) { return cookie != null && !string.IsNullOrEmpty(cookie.Value)); }