Users Online

· Guests Online: 94

· Members Online: 0

· Total Members: 188
· Newest Member: meenachowdary055

Forum Threads

Newest Threads
No Threads created
Hottest Threads
No Threads created

Latest Articles

C# Program to Create a Sealed Class

C# Program to Create a Sealed Class

 

 

This is a C# Program to create sealed class.

Problem Description

This C# Program Creates Sealed Class.

Problem Solution

Here 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.

Program/Source Code

Here is source code of the C# Program to Create Sealed Class. The C# program is successfully compiled and executed with Microsoft Visual Studio. The program output is also shown below.

/*
 * C# Program to Create Sealed Class
 */
using System;
sealed class SealedClass
{
    public int x;
    public int y;
}
 
class SealedTest
{
    static void Main()
    {
        SealedClass sc = new SealedClass();
        sc.x = 100;
        sc.y = 180;
        Console.WriteLine("x = {0}, y = {1}", sc.x, sc.y);
        Console.ReadLine();
    }
}
Program Explanation

In this C# program, we have already defined the values of ‘x’ and ‘y’ variable as 100 and 180 respectively. The sealed classes are used to restrict the inheritance feature of object oriented programming. Once a class is defined as a sealed class, this class cannot be inherited.

 
Runtime Test Cases
 
x = 100 ,y = 180

 

Comments

No Comments have been Posted.

Post Comment

Please Login to Post a Comment.

Ratings

Rating is available to Members only.

Please login or register to vote.

No Ratings have been Posted.
Render time: 0.82 seconds
10,835,471 unique visits