How can I pass an enum as one of the parameters of the method? I only need in some implementations of the method, and not in others. That’s how method declaration looks:
public abstract void SomeMethod(params object[] someParams);
And that’s how I would like some of the implementations to look:
public override void SomeMethod(params object[] someParams) {
SomeEnum someEnum = someParams[0];
if (someEnum == null)
return;
}
This code, of course, is invalid, but it shows what I intend to do. Other implementations of the method may use other enums, or use no enums at all.
Update: As many have stated, it’s a very strange thing to do, throwin type-safety out of the window. So, I decided to explain why I’m doing this.
I have to pass method calls to a lot of various subclasses of a class where I declare this method through a system that sends them across a network (as well as locally) and executes them at specific time in a special order. Is there a better way to do this?
Though quite why you wouldd want to do this over an explicitly typed parameter I cannot imagine.