Set the interface method with different parameters in C #

advertisements
interface parentInterface
{
   public String methodA(/*define parameters name and dataType*/);
}

and

public class childA : parentInterface
{
  public String methodA(String a, int b, String c, long d){}
}

public class childB : parentInterface
{
   public String methodA(int e, String f, String g){}
}

I want to define interface method's parameters name and data type


You have two different methods

public String methodA(String a, int b, String c, long d){}

and

public String methodA(int e, String f, String g){}

that represent two different contracts to childA and childB respectively. You cannot define an interface with a single methodA that fits both definitions. What you seek to do is not possible.

Note that you could define both overloads in your interface, but then each class implementing that interface would have to implement both overloads.