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
You can also call me at +91 0 9873441834
Thanks for your attention
Thursday, July 31, 2008
Subscribe to:
Posts (Atom)
