Can you override private virtual methods?
Answer Posted / vivek
virtual or abstract members cannot be private.
Ex: error occurs during the static compilation phase, which
means that no program that declares a private virtual method
will ever be executed in any way.
C#
class A
{
private virtual int Test()
{
return 1;
}
}
class Program
{
static void Main()
{
}
}
Compile-time error
Error 1
'A.Test()': virtual or abstract members cannot be private
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Difference between directcast and ctype.
Why is it important to override gethashcode when equals method is overridden?
What is data types in c#?
How is a strongly-named assembly different from one that isn’t strongly-named?
What is getenumerator?
What is inline function in c#?
What is the c# equivalent of c++ catch (...), Which was a catch-all statement for any possible exception?
What happens if a static constructor throws an exception?
Why do we use classes?
Why constructor is used in c#?
What is console readkey in vb net?
What are the different types of literals in c#?
What is native image generator (ngen.exe)?
What is difference between event and delegate in c#?
What is encapsulation in csharp?