What is class with example

In this article I'm going to explain What is class with example.

What is Class?

Class is simply a representation of a type of object. It is the template / blue print that describe the detail of an object.
Class is a group of related methods and variables. The class can have any of the following members.
Class are reference type. Classes will support inheritance.Classes can have explicitly parameterless constructors.
Member variable initialization is possible in class.It is possible to declare destructor in class.

1) Fields
2) Properties
3) Method
4) Events
5) Constructors
6) Destructor
7) Delegates
8) Indexers


Methods are used to perform some task.


Same name as class name its called Constructors.

Fields :-

A field is the variable created within the class and its used to store data of the class.


Properties are used to provide access to ther private fields of the class.A property contains two accessors, get and set

Class Example:-

using System;

class PerlClassExample
string _name;
public PerlClassExample()
// Assign this._name
this._name = "Kumar";
// Assign _name
_name = "Rengan";

// The two forms reference the same field.

class ExampleProgram
static void Main()
PerlClassExample objectPerlClassExample = new PerlClassExample();




No responses found. Be the first to comment...

  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name: