【发布时间】:2021-08-09 16:24:05
【问题描述】:
给定两个相互继承的类 (Animal -> Cow) ,子类覆盖一个方法 (MakeSound)。当我遍历动物列表并编写以下内容时:
if(animal is Cow){
如果我想在 if - 语句中添加:
animal.MakeSound();
自动完成将其更改为:
((Cow)animal). MakeSound
这本身并没有错,但在很大程度上是多余的,因为我覆盖了 MakeSound,因此不需要强制转换为 Cow。
有没有办法在 VS for Mac 中禁用这种多余的自动完成行为?
【问题讨论】:
标签: c# autocomplete polymorphism