I have enum with values, I set that enum to be Nullable, this due to fact I dont want to add a MyEnum.NotAvilable state. My problem begins when I send this enum as parameter to function, It will display message:
"The best overloaded method .."
I guess this is because the enum is nullable. The only thing that will work is if when sending the enum to function, I cast the enum to MyEnum or change the signature of foo to accept MyEnum? and not MyEnum.
enum is defined:
public MyEnum? Test
calling a function with signature: private void Foo(MyEnum value)
Foo(MyEnum value); // not working
Foo(MyEnum? value); // works
My question is - Is it bad practice to cast to MyEnum before sending it to Foo ?
if (value.HasValue)
Foo((MyEnum) value); //this makes Foo(MyEnum value) valid