how to write interface

Posted by Oswaldlily under C# on 8/22/2012 | Points: 10 | Views : 863 | Status : [Member] | Replies : 2
interface Iname
{
void function1(this);
}

Error:Type expected in "this"
i m tryin to pass formname in interface function..
why this error?




Responses

Posted by: Pgayath on: 8/31/2012 [Member] Starter | Points: 25

Up
0
Down
hi,

If you trying to pass the form name, it should be something like

interface Iname 

{ void function1(string strFormName); }


else if you are trying to pass the form itself it shud be something like below

interface Interface1

{ void function1(System.Windows.Forms.Form obj); }


Thanks and Regards,
Gayathri P

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

Posted by: Vijay.K on: 9/7/2012 [Member] Starter | Points: 25

Up
0
Down
When writing your own, you just use the keyword interface instead of class, and then don't include the method implementations. Like this:

public interface MyInterface {
public void someMethod(long someParam);
}





public MyClass implements MyInterface {
//since I said "implements MyInterface", //I must include this method, or
//this class won't compile
public void someMethod(long someParam) {
//this is my implementation.
}
}

vijay.k

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

Login to post response