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

Are c# objects passed by reference?

851


What is yield return in c#?

911


Why do we need structs in c#?

827


what is difference between destruct or and garbage collection ?

894


What is expandoobject in c#?

862


Write the syntax for catching an exception in c#?

863


What is difference between il and dll ?

958


Is c# queue thread safe?

908


What is func delegate in c#?

906


What is task parallel library?

985


How is method overriding different from overloading?

1005


Is array passed by reference in c#?

932


What is difference between array and arraylist in c#?

915


Which is more efficient for loop or while loop?

840


Differentiate between sqlclient oledb and providers?

921