24 August 2007

See this example here.

I have created an interface.
public interface myInterFace1
{
void Operation(string myParam);
string myName();
}
it have two methods. Operation and myName.

Now create a class.
class Program
{

}
Now, lets inherit with interface.
    class Program:myInterFace1
{

}
Now I'm using myInterFace1 in Program class, So I need to write down all methods of that interface in my class.

it's do that with rick.

Right click on inter face name near (:) sign.
It will pop up a menu, where you found "Implement Interface" menu.

Click on that menu.

class Program:myInterFace1
{
static void Main(string[] args)
{
}

#region myInterFace1 Members

public void Operation(string myParam)
{
throw new Exception("The method or operation is not implemented.");
}

public string myName()
{
throw new Exception("The method or operation is not implemented.");
}

#endregion
}
All method of that interface will be write down there in that class automatically.

It's a very small but useful example during the development of code.

0 comments :

Post a Comment