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

Why static variables are used?

1022


Explain the difference between object type and dynamic type variables in c#?

934


Can a constructor be static in c#?

1005


How does the clr work?

907


Can we inherit two classes in c#?

949


What is the difference between gettype and typeof in c#?

905


Does constructor return any value in c#?

948


How do you clear a list in c#?

904


Explain the mechanism of VB.NET/C# achieve polymorphism?

993


Describe ways of cleaning up objects in c#.

900


Explain the process of polymorphism with an example?

908


What is assembly c#?

877


How to implement singleton design pattern in c#?

877


What does || mean in programming?

971


What is the difference between c and c# programming?

945