您的位置:首页 > Web前端

Item 10: Use Optional Parameters to Minimize Method Overloads(Effective C#)

2011-01-18 21:16 459 查看
  Therefore, adding parameters, even if they are optional parameters, is a breaking change at runtime. If they have default values, it’s not a breaking change at compile time.  Now, after that explanation, the guidance should be clearer. For your initial release, use optional and named parameters to create whatever combination of overloads your users may want to use. However, once you start creating future releases, you must create overloads for additional parameters. That way, existing client applications will still function. Furthermore, in any future release, avoid changing parameter names. They are now part of your public interface.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: