- What's the difference between a clustered and non-clustered index in SQL Server?
- What's the virtual keyword in C# mean?
The short of it is that virtual is required if you want to override a method of the base class. If you don't supply virtual, the best you can do is use the new keyword to create a completely new method that just happens to have the same name of a method in the base class. To take it a bit further, sealed will prevent any further overriding down the inheritance chain. Therefore;
Is this an important question? Not in-itself. I was offered the jobs without knowing the answer.
I have written an example gist to further clarify.
- a base class may have a method with virtual assigned to it;
- deriving from 1, you could override the method;
- deriving 2, you could sealed override the method;
- deriving 3, you can't override any more (but you could new the method);
Is this an important question? Not in-itself. I was offered the jobs without knowing the answer.
I have written an example gist to further clarify.
No comments:
Post a Comment