i have a question, why there is a partial class and a virtual method in c#?
i mean what is the difference when i have a normal or abstract class and then inherit from it or make it partial?
the other question is why i need virtual methods? when i inherit from a class i also can override the method if i want.
Partial classes: they’re mostly there to allow machine-generated code to be combined with manually-generated code at compile time, to avoid abusing inheritance etc. It can be used for other reasons, but that’s the main purpose of them. No more source files with “don’t edit this bit – it belongs to the designer” etc.
Virtual methods: no, you can’t override a member if it’s not declared virtual (or abstract) in the base class. You can shadow it with
new, but that’s not the same as overriding it – the new method won’t be called polymorphically.