Click to See Complete Forum and Search --> : interface as a parameter


jss3426
August 5th, 2008, 08:47 PM
anyone can point me as to how to one can pass an interface as a parameter? how i go about implementing the code below?

<code>
public class A
{
public void dome(IDo intface)
{
intface.callme();
}

public void Method()
{
MessageBox.Show("A");
}
}



public interface IDo
{
void callme();
}

class main
{
A instA = new A();
a.dome(//do i send it theimplementation? if not where is the implemenation implemented?
}
</code>

boudino
August 6th, 2008, 01:49 AM
Very simple:

class Foo : IDo
{
public void callme() {}
}

Foo f = new Foo();
A instA = new A();
a.dome(f);