How to create method interface with variable parameters / different method signatures?

Replace your args lists with objects that implement a related interface:

public interface IViewModel
{
    //...
    void ResetReferences(IResetValues vals); 
}

I should add that, IMO, ResetReferences() should not take an argument... it should reset to some default value that would be specific to the individual type(s) that implement your interface..."Reset" being the word that means, to me, "restore to initial state"...adding args implies that you can control that.


The purpose of an interface is to have client code know about the interface and be oblivious of the implementation. If your implementations require special treatment when called, the client code need to know what implementation it is calling and then the whole purpose of the interface is lost.

Unless I misunderstand totally what you're trying to accomplish, you're down the wrong road.


If the parameters can be different, then it isn't really a common interface. Put it this way: does the caller need to know the implementation class? If so, you've lost the loose coupling benefits of interfaces.

One option is to encapsulate the parameters into another type, and make the class generic on that type. For example:

public interface IViewModel<T>
{
    void ResetReferences(T data);
}

Then you'd encapsulate the List<Color> colors, List<Size> sizes into one type, and possibly put List<StateProvinces> stateProvinces in another.

It's somewhat awkward though...