Click here to Skip to main content
13,259,539 members (56,847 online)
Click here to Skip to main content
Add your own
alternative version


9 bookmarked
Posted 10 Aug 2006

How to make a class Sealed without Sealed Keyword

, 10 Aug 2006
Rate this:
Please Sign up or sign in to vote.
We can make a class sealed without sealed keyword
<!-- Article Starts - DO NOT ADD HTML/BODY START TAGS-->

Sample Image - Class_Without_Sealed.jpg


An article on how to make a class sealed without using Sealed keyword. The included project includes two ways to make a class sealed using Singleton Pattern and Without singleton pattern.

The class SealedClassSingleton.cs follows a singleton pattern and instance of this class allows to invoke methods of this class.

Another workaround is not to follow singleton pattern and have all static methods and methods can be invoked by the classname as defined in the class SealedClass.cs.

The purpose of above two classes is to make them sealed without using Sealed keyword.

Using the Code

The console application contains an entry point class named clsMain.cs and the Main method in it contains two code blocks to invoke methods of two different sealed classes.

The following code defined in class DerivedClass generates compile time errors when we try to inherit from SealedClassSingleton or SealedClass classes.

public class DerivedClass:SealedClassSingleton //This class is commented as it gives compilation error


public DerivedClass()



// TODO: Add constructor logic here






This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
United States United States
Biswa have been working on Microsoft Technologies since 7 years. For last 3 years he is working on C# as Consultant in Telecommunications sector.

You may also be interested in...


Comments and Discussions

QuestionSealed class without using sealed keyword Pin
VikasAgarwal8417-Oct-11 0:05
memberVikasAgarwal8417-Oct-11 0:05 
GeneralMy vote of 1 Pin
Michael B. Hansen10-May-09 21:22
memberMichael B. Hansen10-May-09 21:22 
Questionwhy? Pin
jan wilmans3-Jul-07 2:03
memberjan wilmans3-Jul-07 2:03 
AnswerThe benefits Pin
mwanyu27-Sep-07 2:42
membermwanyu27-Sep-07 2:42 
GeneralRe: The benefits Pin
screanjap27-Sep-07 3:29
memberscreanjap27-Sep-07 3:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.171114.1 | Last Updated 10 Aug 2006
Article Copyright 2006 by biswam
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid