Thursday, July 31, 2008

Hi Friends

I am Vivek. I am involved in writing code for website application using c# in asp.net. I have seen that developers are using classes but they did not know how we can inherit classes within another classes. How we use multiple inheritance in c#.

I have an idea, so that we can use multiple inheritance in c#. So here we are sharing my idea with you guys.

Introducing Interface

Through Interfaces in C# provide a way to achieve runtime polymorphism.

Syntax For Interface

Please follow bellow code for clear understanding, how we use interface.

//Create Interface

interface Inter1
{
void Fun_xyz();

}

interface Inter2
{
void Fun_aty();

}

interface CombineInter : Inter1,Inter2
{


}

//Declare Class

Class ClsDemo : CombineInter
{

Public void Fun_xyz()
{
System.Console.WriteLine("Using Function xyz");
}

Public void Fun_aty()
{
System.Console.WriteLine("Using Function aty");
}


Public Static void main(String[] args)
{
System.Console.WriteLine("Hello World");

ClsDemo refClsdemo = new ClsDemo();
I
refClsdemo. Fun_xyz();
refClsdemo. Fun_aty();

}
}


Out Put Will Be

Hello World
Using Function xyz
Using Function aty


So how interesting interfaces are. Please mail me if you get something from my understanding about Multiple inheritance in c# and Interfaces. Let me know at vk1979@gmail.com
You can also call me at +91 0 9873441834

Thanks for your attention

6 comments:

Dilip Kumar said...

Really sir g its very use full for beginer as well as professional to use interface.

I hope like this solution in future
all the best

Jyotsna Mishra said...

one of the best learning example.as a beginner in asp.net it helps me to grasp the thing very easily. thnks. do post this kind of things in future

Unknown said...

Gud job sir..this one is very usefull..as in do implement a factory class into next post...which will be quite helpfull for us....

Vivek Kumar said...

Thanks Guys., Next i will add up Factory class in c#.

Anonymous said...

Hi Vivek
You wrote such a nice article. It will really helpful for beginer in asp.net

thanks a lot ans expect more helpful articles in future.

Anonymous said...

Hi Vivek

I want to see more article from your side

Thanks for your great article.