Eric Lippert大大对于"为什么C#/.NET不……"一类的问题是这么回答的:
As I'm fond of pointing out, the answer to every question of the form "why doesn't product X have feature Y?" is the same. It's because in order for a product to have a feature, that feature must be:
- thought of in the first place
- desired
- designed
- specified
- implemented
- tested
- documented
- shipped to customers
You've got to hit every single one of those things, otherwise, no feature.
“支持基于返回值类型的重载”是合理的(Java就可以,如果我没记错的话),但是C#不是Java,它“被设计成了这样”。答案就是这样。另外,如果你真的很需要返回值类型的重载,你可以选择其他的途径去解决,比如泛型或者out关键字一类的。总归是有替代解决方案的。
说得好。
因为返回类型是在返回时才能确定的。
如 int f();与 string f();
系统无法知道你是调用哪个函数,要等到计算结果出来,才知道
如 int f();与 string f();
调用时候写 f();请问是调用哪个呢?返回值我可以丢掉不用,哈哈~~