C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Errors and Solutions » General »

Error Cannot Inherit From Sealed Class


Posted Date: 28 Sep 2008    Resource Type: Errors and Solutions    Category: General
Author: Bindu BujjiMember Level: Gold    
Rating: 1 out of 5Points: 5



Error:

‘SubclassName’ : Cannot Inherit From Sealed Class ‘BaseclassName’

Reason:

Following is the reason why we get this kind of error:

This message indicates that someone has sealed the class , so you can't inherit from it or change any of its properties.

Typically, only library classes are sealed. You can't get around your inability to inherit from the sealed class.





Responses

Author: pavan dwivedi    13 Dec 2008Member Level: Silver   Points : 2
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"); }
}




Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
Sealed class  .  ‘SubclassName’ : Cannot Inherit From Sealed Class ‘BaseclassName’  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: 'ClassName’ Does Not Implement Interface Member ‘MethodName’
Previous Resource: Unable to Copy the File ‘ProgramName.exe’ to ‘programName.exe’. The Process Cannot …
Return to Discussion Resource Index
Post New Resource
Category: General


Post resources and earn money!
 
Related Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use