為什么C#和VB.net都不支持基于返回值類型的重載
3 回答
皈依舞
TA貢獻1851條經驗 獲得超3個贊
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關鍵字一類的。總歸是有替代解決方案的。
- 3 回答
- 0 關注
- 581 瀏覽
添加回答
舉報
0/150
提交
取消
