find and solve || findandsolve.com
Please wait.....

Inheritance In C#

 Object-Oriented Programming Concepts

Object oriented programmming(OOP) is a programming language where programs are organized around objest ato action and logic.
This is  the most popular programming languages in c# including abastraction,encapsulation,inheritance and polymorphism.

Object Oriented  has the following important features. 

Class

A calss is the core of nay mordern object oriented programming language.
OOP language compalsory  to create a class for representing data.
Class is a collection of method and variables.We can define a class using the class keyword in c#.
 

For Example

        class Artical
        {

        } 

Object

Objest are the basic run-time entities of an object oriented programming system.
"An object is an instance of a class"
The classes are regarded as types for instances and instances can not change their type as runtime.

For Example

Syntax to create an object of class Artical

Artical objArical=new Artical();
All the programming languages supporting Object Oriented Programming will be supporting main concepts given below, 

 I.    Encapsulation
  II.    Inheritance
  III.    Polymorphism
 

Inheritance 

Inheritance is one of the fundamental attributes of OOP.The most important or one of the primary concepts in object-oriented programming is inheritance.The most important or one of the primary concepts in object-oriented programming is inheritance,
This is use to inherit the properties from one class  to another class [one class is base class and antoher class is child class].That is,a class can inherit only from a single class.For example, "Salary" can inherit from type "StaffSalary", which inherits from type 
"StaffInfo", which inherits from the base class type "Emplyee". 
Because inheritance is transitive, the members of type "Emplyee" are available to type "Salary".
All members are not a base class are inherited by derived classes.The given below members are not inherited:

Static Constructors:A static constructor is used to initialize any static data.Needs to be performed once only.  

 class StaticExample
        {
            // initialized at run time. 
            static readonly long toBaseline;
            // called at most one time, before any
            static StaticExample()
            {
                toBaseline = DateTime.Now.Ticks;
            }
        }

Static constructors have the following given  properties:
1.    Does not take access modifiers.
2.    A struct or class can only have one static constructor.
3.    Cannot be inherited or overloaded.
4.    A static constructor cannot be called directly.
5.    The static constructor is executed in the program,The user has no control on.
 

Instance constructors:
Finalizers:This is also called destructors.

Remarks 
1.    cannot be defined in structs.
2.    They are only used with classes.
3.    A class can only have one finalizer.
4.    Cannot be inherited or overloaded.
5.     Invoked automatically.
6.    Does not take modifiers or have parameters.

For example, A declaration of a finalizer for the Vehicle class.

 class Vehicle
       {
            ~Vehicle()  // finalizer
            {
                // cleanup statements...
            }
        }
            ~Vehicle()  // finalizer
            {
                // cleanup statements...
            }
        } 

Sundar  Neupane

Sundar Neupane

I like working on projects with a team that cares about creating beautiful and usable interfaces.

Comments



Report Response