Saturday, September 25, 2010

Sealed,Partial Classes and Inheritance


Sealed Classes:

Classes which cannot be inherited are nothing but sealed classes.

Partial Classes:

It is possible to split the definition of a class or a struct, or an interface over two or more source files. Each source file contains a section of the class definition, and all parts are combined when the application is compiled.

Inheritance:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Csharp
{
    class Inhertiance
    {
        public static void Main(string[] args)
        {
            Reptiles obj = new Reptiles();
            obj.Birds();
            obj.Mammals();
            obj.reptiles();
            Console.ReadLine();
        }
     
    }
    class animals
    {
        public void Mammals()
        {
            Console.WriteLine("The rat belongs to mammals family");
        }
        public void Birds()
        {
            Console.WriteLine("The eagle belongs to birds family");
        }
    }
    class Reptiles : animals
    {
        public void reptiles()
        {
            Console.WriteLine("The snake belongs to reptiles familY");
        }
    }
}

No comments:

Post a Comment