|
-
August 5th, 2008, 08:47 PM
#1
interface as a parameter
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>
-
August 6th, 2008, 01:49 AM
#2
Re: interface as a parameter
Very simple:
Code:
class Foo : IDo
{
public void callme() {}
}
Foo f = new Foo();
A instA = new A();
a.dome(f);
- Make it run.
- Make it right.
- Make it fast.
Don't hesitate to rate my post. 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|