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...

is it possible to inherit a class but methods declared in
the class should not be inheritable i possible how?

Answer Posted / ashish modi

class X
{
protected virtual void F() { Console.WriteLine("X.F"); }
protected virtual void F2() { Console.WriteLine
("X.F2"); }
}
class Y : X
{
sealed protected override void F() { Console.WriteLine
("Y.F"); }
protected override void F2() { Console.WriteLine
("X.F3"); }
}
class Z : Y
{
// Attempting to override F causes compiler error
CS0239.
// protected override void F() { Console.WriteLine
("C.F"); }

// Overriding F2 is allowed.
protected override void F2() { Console.WriteLine
("Z.F2"); }
}

Is This Answer Correct ?    12 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are All kind of access specifiers for a class and for methods

1123


What is data dictionary in c#?

1016


What does using do in c#?

951


What are different types of Delegates in C#?

1062


What is the difference between CONST and READONLY?

1132


What is the advantage of static class in c#?

1000


Why do we use class in c#?

978


What is difference between a constant and read-only in C#?

1018


Which is better javascript or c#?

962


Explain dataadapter.update method in .net?

1024


What is the difference between out and ref in c#?

1110


What is an extension method in c#?

1034


Why use a singleton instead of static methods?

945


What is a static class in c#?

1059


User's session is explicitly killed by which method ?

1022