OOP Concepts briefly

November 20, 2007 1 comment

Before Talking about ” OOP Concepts ” we must ask ourselves three simple questions:-

What Is Object-Oriented Programming?

Object-oriented programming is a relatively new approach to creating computer applications that seeks to address many of the problems with so-called traditional programming techniques.

What is Object Technology ?

Object Technology is developing software based in objects

an Object is a combination of data and functions

Why  Object Technology ?

object technology makes a natural way of thinking – about problem domain, not about processes and procedures.

Any full OOP programming Languages must have these four features:-

  • Encapsulation
  • Abstraction
  • inheritance
  • Polymorphism

First we will talk about Encapsulation concept(classes , objects , methods, access modifiers , etc) :

  • Performing a task in an application requires a method. The method describes the mechanisms that actually perform its tasks. The method hides from its user the complex tasks that it performs, just as the accelerator pedal of a car hides from the driver the complex mechanisms of making the car go faster.

Ex:- Simple Method  implementation

// Public is the access modifier of the method and void is the return type

Public void accelerat()



  • Class is an application unit that house for method and other things just as a car’s engineering drawings house (among other things) the design of an accelerator pedal. In a class, you provide one or more methods that are designed to perform the class’s tasks. Just as you cannot drive an engineering drawing of a car, you cannot “drive” a class. Just as someone has to build a car from its engineering drawings before you can actually drive a car, you must build an object of a class before you can get an application to perform the tasks the class describes.

Ex- Simple Class code implementation

Using system;

class pedal



  • Interfaces : An interface is a collection of public methods and properties that are grouped together to encapsulate specific functionality. Once an interface has been defined, you can implement it in a class. This means that the class will then support all of the properties and members specified by the interface.

  • Access modifier is a keyword used to provide the means for determining which code has access to the members of a class

To apply an access modifier to a class member , you simply precede the member with one of the  access modifier keywords .

Public Members access is extended to all code throughout the entire program
Protected Member access is limited to code of the same class and methods of derived classes in the same program
Private Member access is limited to the code within methods of the same class in the same program.
Internal Member access is limited to code within all methods of all classes within the same assembly

Second: Abstraction

  • Classes normally hide the details of their implementation from their clients. This is called information hiding. As an example, let us consider the stack data structure Recall that a stack is a last-in, first-out (LIFO) data structure the last item pushed (inserted) on the stack is the first item popped (removed) off the stack. Stacks can be implemented with arrays and with other data structures, such as linked lists A client of a stack class need not be concerned with the stack’s implementation  . The client knows only that when data items are placed in the stack, they will be recalled in last-in, first-out order. The client cares about what functionality a stack offers, not about how that functionality is implemented. This concept is referred to as data abstraction

Ex:- Simple code of Abstract class implementation

Using system;

Abstract class pedal



Third : inheritance

Inheritance relationships form tree-like hierarchical structures A base class exists in a hierarchical relationship with its derived classes. When classes participate in inheritance relationships, they become “affiliated” with other classes. A class becomes either a base class, supplying members to other classes, or a derived class, inheriting its members from another class. In some cases, a class is both a base class and a derived class as shown in the below figure.

inheritanceInheritance allows you to extend or create more specific classes from a single, more generic base class

Fourth: Polymorphism

Polymorphism enables us to “program in the general” rather than “program in the specific.” In particular, polymorphism enables us to write applications that process objects that share the same base class in a class hierarchy as if they are all objects of the base class.( Ploy ) means “has many forms”. interfaces , abstract methods, virtual methods and override methods is forms of polymorphism.

sealed Methods and Classes

We saw in that only methods declared virtual, override or abstract can be overridden in derived classes. A method declared sealed in a base class cannot be overridden in a derived class . Methods that are declared private are implicitly sealed, because it is impossible to override them in a derived class (though the derived class can declare a new method with the same signature as the private method in the base class). Methods that are declared static also are implicitly sealed, because static methods cannot be overridden either. A derived class method declared both override and sealed can override a base class method, but cannot be overridden in derived classes further down the inheritance hierarchy.


How to program  second edition( C# 2005) [book]

Beginning Visual CSharp 2005 – Wrox  [book]

for more information follow the below link


Categories: C#. Net

Why Is Method Main Declared static?

January 20, 2007 Leave a comment

Why must Main be declared static ? During application startup when no objects of the class have been created, the Main method must be called to begin program execution. The Main method is sometimes called the application’s entry point. Declaring Main as static allows the execution environment to invoke Main without creating an instance of the class. Method Main is often declared with the header:

public static void Main( string args[ ] )

Categories: C#. Net

First post

October 22, 2006 Leave a comment

hi every one

My name is Mostafa Mahmoud from el kenany family ,B.Cs of Computer Science Department of Information System Mansoura University

i am very interested in programming field specially ORACLE Database

i worked under DotNet Framework Technology C# programming langauge ,ADO.Net , ASP.net , XML and do some cool applications and i am still connected with this technology and aware with the new Microsoft Technologies and frameworks


i am working to Develop my technical skills and seeking to get a respectable job opportunity in a respectable IT  Development Company

all i wanna to say this my own blog if you have any comments do not hestiate and enjoy posting & commenting

Categories: About My Self