Monday, April 5, 2010

MULTIPLE INTERFACES HAVING SAME METHOD NAME HOW TO IMPLEMENT AND CALLING

IN VB.NET

INTERFACE1

Public Interface Interface1
sub test()
End Interface

INTERFACE2

Public Interface Interface1
sub test()
End Interface

Class1

Public Class Class1
implements Interface1,Interface2

sub Interface1test ()implements Interface1.test
console.WriteLine("i1")
end sub
sub test() implements Interface2.test
console.WriteLine("i2")

end sub
End Class

WINDOWS Form1

Public Class Form1

Private Sub Form1_Load( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

dim obj_I1 as Interface1=new Class1
dim obj_I2 as Interface2=new Class1
obj_I1.test
obj_I2.test
End Sub
End Class


IN C#


interface Interface1
{
void TEST();
}




interface Interface2
{
void TEST();
}



class MultInterfaces: Interface1,Interface2
{

void Interface1.TEST()
{
int k = 740;
}



void Interface2.TEST()
{


int k = 340;
}
}




private void Form1_Load(object sender, EventArgs e)
{
MultInterfaces obj = new MultInterfaces();
Interface1 obj1=new MultInterfaces();
Interface2 obj2 = new MultInterfaces();
obj1.TEST();
obj2.TEST();
}

No comments:

Post a Comment