Sealing Classes - CSharp Custom Type

CSharp examples for Custom Type:sealed

Introduction

C# provides the sealed keyword to prevent derivation from a class.

Demo Code

using System;//from w w  w  .j a v a 2s. c o m
sealed public class number
{
   private float pi;
   public number()
   {
      pi = 3.14159F;
   }
   public float PI
   {
      get {
         return pi;
      }
   }
}
class myApp
{
   public static void Main()
   {
      number myNumbers = new number();
      Console.WriteLine("PI = {0}", myNumbers.PI);
   }
}

Result


Related Tutorials