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 is difference between a constant and read-only in C#?

912


How do I create a multilanguage?

868


What is difference between int and int in c#?

890


What is a boolean c#?

840


What is generic types in c#?

872


How do I format a string in c#?

803


What is the use of constructor in c# with example?

793


What's the difference between WindowsDefaultLocation and WindowsDefaultBounds?

1105


What is the purpose of static?

924


What is option parameter in C#?

919


Explain the top reason to use c# language?

883


What can you do as a .net developer?

880


Why does dllimport not work for me?

981


Why do we use stringbuilder in c#?

870


What is serializable in c#?

858