What is a Class?


A class is simply a representation of a type of object; think of it as the object's blueprint. Just as a single blueprint can be used to build multiple buildings, a single negative of photographs can be used to print many photos. So a class can be used to create multiple copies of an object. It is the base for the all object oriented programming concepts.


 In everyday programming life, we use this concept throughout our Asp.Net applications. Obviously we are not realizing that we are using these classes from creating a simple Label control to complex WebServices. For example, the TextBox control is defined by a TextBox class, which defines its appearance and its capabilities. Each time you drag a TextBox control onto a webpage, you are actually creating a new instance of the TextBox class. Sometimes you need to create a TextBox from your code-behind, which can be achieved only by creating an object from the TextBox Class as follows 

TextBox TextBox1 = new TextBox();
TextBox1.ID="TextBox1";

When you create an object to the class, all the properties and methods can be accessed by the object or in other word we can say as instance. On the other hand, you can use a class only if you create an object to it. For example, if you consider a Car as a Class, then you need a driver to drive the Car. So the driver can access all the properties, functionalities and methods of the Car.

0 comments:

Post a Comment