Thursday, 17 June 2010

Mulutiple interfaces having same method how to implment and call

c# :
interface Interface1
{
void krs();
}


interface Interface2
{
void krs();
}


class MultInterfaces: Interface1,Interface2
{

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



void Interface2.krs()
{


int k = 340;
}
}




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




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

No comments:

Post a Comment