C# Type IsSealed
Description
Type IsSealed
gets a value indicating whether the Type
is declared sealed.
Syntax
Type.IsSealed
has the following syntax.
public bool IsSealed { get; }
Example
The following example creates an instance of a sealed class, checks for the IsSealed property, and displays the result.
// www. j av a 2s . c om
using System;
namespace SystemType
{
public class MyClass
{
sealed public class MyTestClass
{
}
public static void Main(string []args)
{
try
{
bool myBool = false;
MyTestClass myTestClassInstance = new MyTestClass();
Type myType = myTestClassInstance.GetType();
Console.WriteLine(myType.IsSealed);
}
catch (Exception e)
{
Console.WriteLine("\nAn exception occurred: {0}",e.Message);
}
}
}
}
The code above generates the following result.