How to prevent a class can be inherit in C#

No.of Views2228
Bookmarked0
By RRaveen  On 22 Dec 2010
emailbookmarkadd commentsprint
 

Answer:

If you want to prevent a class to create subclass, the class must be sealed. Most of the security classes are sealed.

Sample Code

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    public sealed class TryCatch
    {
        public void SaveEmployee(string empID)
        {

               // few line of code here            
            
        }
    }
}

 

 
 
About Author
 
RRaveen
Occupation-Software Engineer
Company-TGS
Member Type-Gold
Location-Singapore
Joined date-03 Jun 2009
Home Page-codegain.com
Blog Page-www.codegain.com
- B.Sc. degree in Computer Science. - 4+ years experience in Visual C#.net and VB.net - Obsessed in OOP style design and programming. - Designing and developing Network security tools. - Designing and developing a client/server application for sharing files among users in a way other than FTP protocol. - Designing and implementing GSM gateway applications and bulk messaging. - Windows Mobile and Symbian Programming - Having knowledge with ERP solutions
 
 
Other popular Interview Questions On CSharp
^ Scroll to Top