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 private in c#?
How do you pronounce c#?
Explain the difference between arraylist and array and in c#?
What is windows forms in c#?
What is difference between for and foreach loop in c#?
Illustrate serialization?
What standard types does c# use?
Illustrate race condition?
Is comparable a functional interface?
What is a class level variable in c#?
What is parse method in c#?
What is null propagation c#?
What are custom exceptions in C#?
Is xml tags are case sensitive?
What exception can an overridden method throw in comparison with the method it is overriding?