If I want to create a C# interface with a general "DoProcessing" method that then calls other methods depending on the argument(s) passed in, which is better:
1) Generics, for example:
interface IMyInterface<T>
{
void DoProcessing(T myParam1, string myParam2)
{
// Maybe have a switch statement here to call various methods depending on what value myParam2 has.
}
}
2) Object parameter, for example:
interface IMyInterface
{
void DoProcessing(object myParam1, string myParam2);
{
// Maybe have a switch statement here to call various methods depending on what value myParam2 has.
}
}
For both of the above, the second parameter (myParam2) might be a method name or enum for some kind of state (e.g. "busy", "idle", "blocked").
1) Generics, for example:
interface IMyInterface<T>
{
void DoProcessing(T myParam1, string myParam2)
{
// Maybe have a switch statement here to call various methods depending on what value myParam2 has.
}
}
2) Object parameter, for example:
interface IMyInterface
{
void DoProcessing(object myParam1, string myParam2);
{
// Maybe have a switch statement here to call various methods depending on what value myParam2 has.
}
}
For both of the above, the second parameter (myParam2) might be a method name or enum for some kind of state (e.g. "busy", "idle", "blocked").
Comment