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
Can we inherit static class in c#?
How is the syntax written to inherit from a class in C#?Give an example ?
Why is it not a good idea to use empty destructors?
Constructor to an arbitrary base constructor?
Explain what a diffgram, and a good use for one Define diffgram? How it be used?
Name some string escape sequences in c#.
What is global namespace in c#?
Is system a class in c#?
Why do we use virtual methods in c#?
What are the concepts of dispose method?
What is polymorphism c# example?
Explain copy constructor?
Define a partial class?
What is a lambda expression in c#?
How many constructors can a class have c#?