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 multithreading with .net?
What is func delegate in c#?
How do you prevent a class from being inherited in c#?
Explain about Threading Types.
Is an array an object c#?
What is use of FormBoarderStyle Propertie
Can abstract class have parameterized constructor?
How can we set class to be inherited, but prevent the method from being over-ridden?
Define Final Class in C#
Explain the Usage of web.config
What is lock in c#?
How garbage collection deals with circular references.
How do you define a predicate?
What are the types of attributes in c#?
What is dll in c#?