You are on page 1of 1

Object Oriented Programming Concepts Page 1 of 1

Object-oriented Programming Concepts

An object-oriented program is a collection of objects sending messages to one another. The following table lists
several terms with which you should be familiar.

Term Description
Classes are the basic unit of any object-oriented language.

Classes  Classes are the templates used to create objects.


 Classes can be used to define new data types.
 All programming must be done inside of a class.
 Classes contain member variables and member methods.
An object is an instance of a class.

Object  Instances are created by declaring a variable of the class type to hold a reference to an
instance (or object) of that class.
 Instantiate or create a new instance of a class using the new keyword.
The behavior of the program is defined inside the body of methods.
Method
 All methods must be in a class.
 Methods consist of a header and zero or more statements
The fields of a class are the data members (variables) that are used to track the state of the class.

Fields  Data members are variables declared inside of the class.


 Data members can be variables of any type.
 Data members usually cannot be directly accessed outside of the class.
 Properties provide a nice way of indirectly accessing data members outside of a class.
In a generic sense, a property is any data member or field associated with an object. Properties are
unique to a class instance. In a way, it is the object's properties that differentiate one object from
another. In a strict sense, object properties are better referred to as fields or data members.
Properties
In a formal sense, a property is a programming construct that lets you access (get) or modify (set)
the fields of an object.
An event is a class member that enables an object or class to provide notifications. You can write
Event event handlers that link code to events. When the event occurs, the code in the linked handlers is
executed.
Namespaces are used to organize the program and prevent name collisions.

Namespace  Namespaces contain classes, a variety of other programming constructs, or other


namespaces.
 The System namespace ultimately contains all of the namespaces and classes in the .NET
libraries.

file://G:\Testout\resources\MSDevNet\CSharp\oop.htm 10/17/2010

You might also like