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

Can a method return multiple values in c#?

912


What is expression tree with example?

959


What is marshalling in c#?

919


How can you access a private method of a class?

1071


Does google use c#?

969


Can list contain duplicates c#?

949


Explain polymorphism in c# with a simple example?

988


What is the c# equivalent of c++ catch (…), which was a catch-all statement for any possible exception? Does c# support try-catch-finally blocks?

952


Explain the functionalities of satellite assembly?

1024


Explain what a diffgram, and a good use for one Define diffgram? How it be used?

1054


How do generics work in c#?

958


What are the steps to make an assembly to public?

1028


Can a loop recorder detect a heart attack?

1070


What are the concepts of dispose method?

984


Explain About web methods and its various attributes

1040