方法重载的分辨率和乔恩斯基特的脑筋急转弯 [英] Method overloads resolution and Jon Skeet's Brain Teasers

查看:182
本文介绍了方法重载的分辨率和乔恩斯基特的脑筋急转弯的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

乔恩的脑筋急转弯

< STRONG>在这里剧透...

我看的回答以#1,我必须承认,我从来不知道这是在重载的情况下。但是,为什么这样的情况。在我的小心灵 Derived.Foo(INT)好像逻辑路线走了下来。

I'm looking at the answer to #1, and I must admit I never knew this was the case in overload resolution. But why is this the case. In my tiny mind Derived.Foo(int) seems like the logical route to go down.

什么是这个设计决定背后的逻辑?

What is the logic behind this design decision?

奖励时间!

这是行为C#的规范中,CLR实现,或编译的结果?

Is this behaviour a result of the C# specification, the CLR implementation, or the Compiler?

推荐答案

此行​​为是蓄意的,精心设计的。的原因是因为这样的选择,从而减轻了脆性基类失效的一种形式的影响。

This behaviour is deliberate and carefully designed. The reason is because this choice mitigates the impact of one form of the Brittle Base Class Failure.

阅读我了解更多详细信息的主题文章

Read my article on the subject for more details.

http://blogs.msdn.com/ericlippert/archive/2007/09/04/future-磨合的变化 - 部分 - three.aspx

这篇关于方法重载的分辨率和乔恩斯基特的脑筋急转弯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆