I have an enum of for example ‘Gender‘ (Male =0 , Female =1) and I have another enum from a service which has its own Gender enum (Male =0 , Female =1, Unknown =2)
My question is how can I write something quick and nice to convert from their enum to mine?
Using an extension method works quite neatly, when using the two conversion methods suggested by Nate:
Obviously there’s no need to use separate classes if you don’t want to. My preference is to keep extension methods grouped by the classes/structures/enumerations they apply to.