What is Class?

In OOP class is one of the important elements. This article describes basic overview of class or how to use a class in C#. Summary of the article:

  • What is Class?
  • What is Constructor?
  • What is Destructor?

What is Class?
In Object Oriented Programming (OOP) a class is a representation of a type of object. It is the blueprint or plan or template that describes the details of an object. In .NET a class is User-Defined reference types structure that contains variables and methods.
A class can have one or more subclass that can inherit all or some of the characteristics of the class. The main class is the superclass. Subclasses can have own methods and variables that are not part of their superclass. A class and its subclasses is called the class hierarchy.

What is Constructor?
Constructor is a member function and its name is as like as class name. It is used to initialize the class object. Constructor & Destructor both are necessary for every class. If we don’t create them compiler automatically create them by himself. Constructor & Destructor has no return type. It is called when a class object is created. Constructor & Destructor has no statement primarily. But we can create custom statement. Constructor may have parameter or not.

What is Destructor?
Destructor is used to delete object instance from the memory. We need to destroy object instance after its task. If we don’t does this compiler automatically do this? Its name is as like class name. Only extra ~ sign is used before its name. It has no parameter and it doesn’t accept any operator.

That’s all about C# class.

Comments

  1. By Bijoy Kumar

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *