nedcomp hosting homepage

Producten en diensten
Dedicated servers
Datacenter informatie
Partners, resellers
Helpdesk informatie
Technische docs, tools
Support homepage
ASP componenten
Praktische ASP, ASP.NET
Visual route server
Whois (domein gegevens)
Software documentatie
Whitepapers
Zoeken
Nedcomp / algemeen

Zoeken
 

Copyright © Nedcomp Hosting
Telefoon nr :   +31 184 670111
Fax nummer :   +31 184 631384
E-mailadres :   info@nedcomp.nl
 

C# Programmer's Reference  

sealed

A sealed class cannot be inherited. It is an error to use a sealed class as a base class. Use the sealed modifier in a class declaration to prevent inheritance of the class.

It is not permitted to use the abstract modifier with a sealed class.

Structs are implicitly sealed; therefore, they cannot be inherited.

Example

// cs_sealed_keyword.cs
// Sealed classes
using System;
sealed class MyClass 
{
   public int x; 
   public int y;
}

class MainClass 
{
   public static void Main() 
   {
      MyClass mC = new MyClass(); 
      mC.x = 110;
      mC.y = 150;
      Console.WriteLine("x = {0}, y = {1}", mC.x, mC.y); 
   }
}

Output

x = 110, y = 150

In the preceding example, if you attempt to inherit from the sealed class by using a statement like this:

class MyDerivedC: MyClass {}   // Error

you will get the error message:

'MyDerivedC' cannot inherit from sealed class 'MyBaseC'.

See Also

C# Keywords | Modifiers