How can you force derived classes to provide new method implementations for virtual methods?



How can you force derived classes to provide new method implementations for virtual methods?..

Answer / Gaurav Kumar Varshney

In C#, you can force a derived class to override a virtual method using the 'new' keyword. For example: public class BaseClass { public virtual void MyMethod() { ... } } public class DerivedClass : BaseClass { public new void MyMethod() { ... } }

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More C Sharp Interview Questions

What is the purpose of dictionary in c#?

1 Answers  


What's difference about switch statements in C# ?

1 Answers  


What is the difference between CreateObject() and GetObject()?

1 Answers   CGI,


What is a race condition?

1 Answers  


what is difference between destruct or and garbage collection ?

1 Answers   Wipro,


What are the types of class in c#?

1 Answers  


What is the difference between serialization and deserialization in c#?

1 Answers  


If c# destructors are so different to c++ destructors, why did ms use the same syntax?

1 Answers  


How to use the sreamReader class to read form a text file?

1 Answers   MCN Solutions,


Is linkedhashset synchronized?

1 Answers  


What?s the implicit name of the parameter that gets passed into the class? set method?

1 Answers  


Can variables defined in interface. If yes how we can call/use it in class.

2 Answers   Synechron,


Categories