06-06-2013, 04:14 PM
Classes and Objects
Classes and Objects[.pptx (Size: 98.53 KB / Downloads: 18)
Introduction
C# is true object oriented language, so underlying structure of all C# program is classes
Classes provides the convenient approach for packing together a group of logically related data items and functions
Data items are called field and functions are called Methods
It is user defined data type.
Encapsulation
It provides the ability to hide the internal details of an object from its users
The outside user may not be able to change the state of object directly
However, the state of user be altered indirectly using methods or accessor
This concept is also known as data hiding or information hiding
Inheritance
It is the concept we use to build new class using the existing class
The original class is known as base or parent class
The derived one is known as derived or child class
This concept facilitates the reusability of existing code thus improves the integrity of program and productivity of program
Polymorphism
It is the ability to take more than one form
Operation may exhibit different behavior in different situations
For example , addition of two number would produce sum , and addition of two string would produce new string
2+3 = 5
Abc + def = Abcdef
Overloaded Constructor
It is possible to create multiple methods with same name, but with different parameter list and different definition
This is called method overloading
It is useful , when objects are require to perform similar task , but using different input parameter
This process is also known as polymorphism
To do constructor overloading , we have to provide several different parameter list