Sensato
Sensato
CC#
Created by Sensato on 4/30/2024 in #help
Convert enclosing type - implicit enum conversion
Trying to get Environment.Exit(enum) to accept an enum without explicitly casting the parameter The code below works one-way, but not the other and I'm unsure as to why
public static implicit operator ExitCodes(ExitCodes value) {
return (int)value;
}
public static implicit operator ExitCodes(int value) {
return (ExitCodes)value;
}
public static implicit operator ExitCodes(ExitCodes value) {
return (int)value;
}
public static implicit operator ExitCodes(int value) {
return (ExitCodes)value;
}
I would love to know if anyone has a solution to get this working, I don't want to haver to explicitly cast them every time I make a call using the enum (it will be referenced elsewhere as well
19 replies