Hey folks,
So, I've got three enum types:
enum enum1
enum enum2
enum enum3
And then I've got a function overloaded three times to accept each
enum type:
private void func(enum1 myenum){}
private void func(enum2 myenum){}
private void func(enum3 myenum){}
And then I've got a wrapper function (kind of) which accepts a
System.Enum as a parameter, and then passes that parameter to call the
functions above:
private void funcCaller(System.Enum enumType)
{
func(enumType);
}
Finally the wrapper function is called passing it one of the enum
types
funcCaller(enum1);
funcCaller(enum2);
funcCaller(enum3);
This fails however inside funcCaller with the error:
Argument '1': cannot convert from 'System.Enum' to 'enum1'
So, basically it seems it's not doing implicit casting. I know there
are other ways to accomplish what I need to do, but this is the way
I'd like most to do it, so before I move on, does anyone know how I
can get this to work in this manner? How can I get the line inside
funcCaller to work? Is it just a matter of using a typeof or
something? I don't want to use a switch statement in there because I
don't want to update it everytime a new enum is created.
This ic C# 1.1 by the way...so no generics!
Thanks a lot!