Monday 13 April 2015

Sealed Class in C# Programming

Hello Friends,
                  Previous Chapter I have described oop concept but now I will expain anther concept i,e.Sealed class in C# dot.Generally it is opposite of abstract class  and  it can't  inherited  because when we will create a class as sealed modifier then it will prevant to inherit from this class.

Suppose class c1 and class c2 are two class if we declare sealed to any class that canot be inherit ,just see that small example in below.

Class c1
{
}
sealed class c2:c1
{

}
Note:Now just see that class c2 inherit from class c1,but at 2nd step we have declaed class c2 as sealed so for that reason there is not possible thatno class can inherit from class c2 if we will do than that fire error.

Ex:

using System;

namespace sealedclass
{
sealed class mysealedclass
{

Pure Abstract class in C# dot net

Hello Friends,
Now I am going to describe anther concept i.e.Pure abstract class.It is a extended version of abstract class.which contains only abstract methods but we can't declare a body inside this abstract method.
But the disadvantages of pure abstract class is that this class can't inhert multiple time means that multiple pure abstract class is not possible.So To overcome this problems interface concept is introduced.

Ex:

using System;

namespace pureabstractclass
{
abstract class pureabstract
{
public abstract void mypureabs ();
public abstract void mypureabs1 (int s,int p);
}

Encapsulation in C# dotnet



Hello Friends,                                                                                                                          
                 Now I am going to describe anther oop concept in C#.net i.e. Encapsulation.It  is a  Mechanism which is responsible to hide all internal part of an object  from outer world  and  It’s scope of access and visibility depends upon the access specifier.By using this technique  Data member and member function bind a single unit which leads to data security.
 RealWorldExample                                                                                                                                                                                         When we use computer keyboard for input data at that time we can’t know the internal process means  how it execute internally.
Ex:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace encapsulationprog
{
    class encaps
    {
        private int myencaps1;

Sunday 12 April 2015

Abstract Class Concept in C#.net

Hello Friends,
            Now I am going to describe anather OOP concept of C# dotnet.Generally Abstraction is a concept through which we can see only assential part of the object ,we can't see the background details or inner part of the object.
                               If we will see the real world example than this concept will be cleared.when we are watching TV then through our Remote we controls any operations means we can move one chanel to anather chanel to enjoy different programs that can be news,songs and serial etc.
             But matter is that when we are enjoying any program in TV at that time we don't try to see any background part of TV like picture tube,circute,electronics chips etc and we donot know about it's internal process or how it work.
        Finally we can say that it is a concept through which the essential part of the object will represented hiding the background detail.It leads to data hiding and data hiding leads to data security.

Ex:
Abstract Class:
       Abstract class is a type of class whose data member and member function can be accessed in derived class.The members of abstract class can be private as well as protected.It is define by abstract key word.
Ex:
using System;

namespace abstractclass
{
abstract class abstractprog
{

Saturday 11 April 2015

Interface Concept of C# dotnet

Hello Friends,
                                Now I am going to describe the Concept of Interface in C# dot net.Interface is a identical with pure abstract class but advantages of Interface is that multiple interfaces can be implimented.
                 Using this concept We can also invoke the functions from different classes through the same Interface reference.
               It declared by Iterface keyword and deafult behavier of Interface is Public.

Ex:

using System;

namespace Interfaceprog
{
interface myinterfaceA
{
void myfirstinter();
void mysecondinter (string s);
}

Inheritence Concept of C# dotnet

Hello Friends,
                             In previous chapter I had described the concept of polymorphism,Now I am going to describe anather concept of OOP i.e.inheritance .It is a concept in oop which leads to reusability functionality.
                   It means When a class derived from anather class then the members of base class become the members of derived class.By this technique the data member and member function of one class can reuse in anather class.
C# dotnet supports 3-Types of Inheritance:

1.Simple or Single Inheritance
2.Multilevel Inheritance
3.Hierachical Inheritance

*Note:-Instead of Multiple Inheritance a new technique is introduced,i.e. called Interface.
  •      Next chapter I will describe about the concept of Interface.
Simple or Single Inheritance:
when a single derived class is derived from a single base class .It means that one base class having one derived class then this concept is called Single or Simple Inheritance.

Ex:
 using System;

namespace Inheritance
{
class mybaseclass //Base class
{
public void mybase()
{