What is the difference between the override and new keywords in C#?

后端 未结 5 1170
无人共我
无人共我 2020-11-28 21:49

What is the difference between the override and new keywords in C# when defining methods in class hierarchies?

5条回答
  •  独厮守ぢ
    2020-11-28 22:45

    Looks like an old question, let me try a different answer:

    1. new : as the name says, it is a new member in the family of inheritance hierarchy and this will be used as base member for further down the chain (if marked as virtual).

    2. override : It means I don't accept my parent class' member implementation and I will do differently.

提交回复
热议问题