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...

What are Sealed Classes in C#?

Answer Posted / saba

Sealed classes are used to restrict the inheritance feature
of object oriented programming. Once a class is defined as
sealed class, this class cannot be inherited.

The following class definition defines a sealed class in C#:


// Sealed class

sealed class SealedClass

{

}

In the following code, I create a sealed class SealedClass
and use it from Class1. If you run this code, it will work
fine. But if you try to derive a class from sealed class,
you will get an error.


using System;

class Class1

{

static void Main(string[] args)

{

SealedClass sealedCls = new SealedClass();

int total = sealedCls.Add(4, 5);

Console.WriteLine("Total = " + total.ToString());

}

}

// Sealed class

sealed class SealedClass

{

public int Add(int x, int y)

{

return x + y;

}

}

Is This Answer Correct ?    2 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I trim a space in c#?

905


What is a generic method?

971


What is inner class in c#?

974


Why abstract class can not be instantiated?

874


Why reflection is used in c#?

940


What is meant by clr?

1003


what are the contents of an assembly ?

993


What is use of FormBoarderStyle Propertie

934


What is difference between an Structure and Class?

1123


What is msil in c#?

959


hi, is compulsory .net knowledge need for biztalk server training. if need, how far?.tell me some info abt real time instructors in hyd or other?

1543


What are examples of desktop applications?

967


What are the advantages of constructor?

857


What do you understand by 'access specifiers' in C#?

898


What is difference between array and list in c#?

863