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 we extend static class in c#?

860


Explain how obfuscator works in .net

951


Which framework is best for desktop application?

934


What is Fragmentation and its Types?

943


What is the difference between do and while loop?

841


What is better C# or VB.NET?

874


Can we override constructor in c#?

878


Why do we need generics in c#?

873


What are the properties of string?

907


What is remote data?

790


What's c# ?

940


Why is xml called extensible?

821


Can datetime be null c#?

821


Explain the functionalities of satellite assembly?

904


What is the difference between ref and out in c#?

850