Ray's playground

 

2011年2月19日

Item 30: Prefer Overrides to Event Handlers(Effective C#)

摘要: When you have one function that handles one event in a derived class, theoverride is the better approach. It is easier to maintain, more likely to becorrect over time, and more efficient. Reserve the event handlers for otheruses. Prefer overriding the base class implementation to attaching an eventh 阅读全文

posted @ 2011-02-19 13:06 Ray Z 阅读(199) 评论(0) 推荐(0) 编辑

Item 29: Support Generic Covariance and Contravariance(Effective C#)

摘要: It certainly can get complicated describing exactly how covariance andcontravariance work. Thankfully, now the language supports decoratinggeneric interfaces and delegates with in (contravariant) and out (covariant)modifiers. You should decorate any interfaces and delegates you definewith the in or 阅读全文

posted @ 2011-02-19 11:12 Ray Z 阅读(142) 评论(0) 推荐(0) 编辑

导航