Answer Posted / dharmendra nonia
No,We can't override the private virtual method because
it private access specifier does not allow to inherit the
private member of a class in a derived class.
Ex:--
-------
using System;
public class ABC
{
private virtual void mm()
{
}
}
public class abc:ABC
{
private override void mm()
{
Console.WriteLine("Hello");
}
}
class d:abc
{
public static void Main()
{
d D=new d();
D.mm();
}
}
Output:-
--------
ae.cs(4,23): error CS0621: 'ABC.mm()' : virtual or abstract
members cannot be
private
ae.cs(11,24): error CS0621: 'abc.mm()' : virtual or
abstract members cannot be
private
| Is This Answer Correct ? | 6 Yes | 0 No |
Post New Answer View All Answers
What is bitwise operator in c#?
Will the following code compile?
What is class method?
Which is faster abstract class or interface in c#?
Can you put two constructor with the same structure in a class?
What is dictionary class in c#?
How to find Percentage, name ,College from a resume or document ? How to export these values to other page in C#?
Why main is static in c#?
What is the difference between func and action delegate?
What is generic delegates in c#?
What is unrecognized escape sequence in c#?
What is thread.sleep()?
in the nunit test framework, which attribute must adorn a test class in order for it to be picked up by the nunit gui?
List the difference between interface and abstract class?
What is winforms c#?