您的位置:首页 > Web前端

Item 40: Use Dynamic for Parameters That Receive Anonymous Types(Effective C#)

2011-02-26 10:38 555 查看
You can leverage dynamic to create methods that are intended to be used with anonymous types. It’s a technique to be used sparingly, like strong spices. If you find yourself creating many methods using dynamic invocation that are intended for use with anonymous types, that’s a strong indication that you should create a concrete type to represent that concept. It will be much easier to maintain over time, and you’ll have better support from the compiler and the type system. However, when you need one or two utility methods that use an anonymous type, dynamic invocation is a simple way to create that behavior.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐