Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Can you override private virtual methods?

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


Please Help Members By Posting Answers For Below Questions

Can we inherit static class in c#?

954


How is the syntax written to inherit from a class in C#?Give an example ?

1030


Why is it not a good idea to use empty destructors?

997


Constructor to an arbitrary base constructor?

946


Explain what a diffgram, and a good use for one Define diffgram? How it be used?

963


Name some string escape sequences in c#.

1001


What is global namespace in c#?

945


Is system a class in c#?

882


Why do we use virtual methods in c#?

913


What are the concepts of dispose method?

889


What is polymorphism c# example?

891


Explain copy constructor?

1112


Define a partial class?

869


What is a lambda expression in c#?

1445


How many constructors can a class have c#?

871