Is it possible to have multiple interface in a single class ? if so how ?

Posted by Nav234 under DotNetFunda.Com on 6/26/2010 | Views : 1878 | Status : [Member] | Replies : 1
Hi all

In our application (either in c# or vb.net),

Is it possible to have multiple interface in a single class ?
if so how ? and if so ,

in the following scenario ,

Single Class

{
interface 1;
interface 2;
interface 3;
}

In this ,how the program identifies and which interface runs
first ,second and third...

Thanks in advance

S.Naveen...


Responses

Posted by: BangaruBabu on: 6/27/2010 [Member] Starter

Up
0
Down

Yes you Can

using System;

interface InterFace1
{
void TestMethod();
}

interface InterFace2
{
int TestMethod2(int a, int b);
}

class MyClass : InterFace1, InterFace2
{
public static void main()
{
int num1 = 23;
int num2 = 6;
MyClass cls = new MyClass();
cls.TestMethod();
int tot = cls.TestMethod2(num1, num2);
Console.WriteLine(tot.ToString());
}
public void TestMethod()
{
Console.WriteLine("test method");
}

public int TestMethod2(int a, int b)
{
return a + b;
}
}


BangaruBabu Pureti
http://bangarubabupureti.spaces.live.com/

Nav234, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response