Pages

Sunday, May 12, 2013

oops concept in c#

Object Oriented Programming language(OOPS):
 It is a methodology to write the program where we specify the code in form of classes and objects.

Basic Principle of oops:- There are main four core principles of  any object oriented languages.
1.Abstraction
2.Encapsulation
3.inheritance
4.polymorphisim

Note: If any programing languge supports abave give 4 support is called oops

1.Abstraction :

Hidding the implementation details and Exposing the required details of the user.
Types:
  a.Data abstraction or data hidding
 b.Behaviour abstraction or impliment hidding

2.Encapsulation:

It is nothing but binding the related variables and behaviour in a common place
-> Better mantainability is the primery advantage .

3.inheritance:

By using inheritance we can achive code resability 
->Better mantenability
->Avoid duplication
Types:
1.single
2.multiple
3.multilevel
4.hybrid

 sample code:

public class test
{
protected void page_load(-,)
{
  B b=new B();
   b.m();    // without create object we can access methods and variable(only possable inheritance)
  b.m1();
public class A
 {
  public int x=20;
 public int m()
    {
      return 200;
   }
public class B:A
  {
    public int y-30;
   public string m1()
    {
      return "mother";
   }
}

4.polymorphisim:

{ all the details for this one another post}

 

No comments:

Post a Comment