Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 3 years ago.
重载对性能没有影响;它由编译器在编译时解决。
至于设计指南,请参阅设计指南:
http://msdn.microsoft.com /en-us/library/ms229029.aspx
Overloading has no impact on performance; it's resolved by the compiler at compile-time.
As for design guidance, see the design guidelines:
http://msdn.microsoft.com/en-us/library/ms229029.aspx
如果您使用的是 C# 4.0,您可以节省一些工作并使用 可选参数。
If you're using C# 4.0 you can save your fingers some work and use optional parameters.
远离性能,如果集中使用重载肯定会导致混乱,一旦有人开始维护代码,我更喜欢这样做:
Person GetPersonByID( int id ); Person GetPersonByName( String name );
对此:
Person GetPerson( int id ); Person GetPerson( String name );
Away from performance, overloading if used intensively will for sure lead to confusion once somebody starts to maintain the code, I prefer doing this:
on this:
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
暂无简介
文章 0 评论 0
接受
发布评论
评论(4)
重载对性能没有影响;它由编译器在编译时解决。
至于设计指南,请参阅设计指南:
http://msdn.microsoft.com /en-us/library/ms229029.aspx
Overloading has no impact on performance; it's resolved by the compiler at compile-time.
As for design guidance, see the design guidelines:
http://msdn.microsoft.com/en-us/library/ms229029.aspx
如果您使用的是 C# 4.0,您可以节省一些工作并使用 可选参数。
If you're using C# 4.0 you can save your fingers some work and use optional parameters.
据我所知,这就像定义一个新方法。性能影响是硬盘上的空间。
确实,它提供了便利,
尽可能多的硬盘空间。
as far as I know, it's like defining a new method. The performance impact is space on your harddrive.
Definitely, it's provides convenience
As much Harddrive space as you have.
远离性能,如果集中使用重载肯定会导致混乱,一旦有人开始维护代码,我更喜欢这样做:
对此:
Away from performance, overloading if used intensively will for sure lead to confusion once somebody starts to maintain the code, I prefer doing this:
on this: