As C# lacks support for freestanding functions, I find it hard to find a place to put conversion functions. For example, I'd like to convert an enum to a number. In C++, I would make the following freestanding function for this:
UINT32 ConvertToUint32(const MyEnum e);
How can I elegantly do this in C#? Should I make a dummy static class for holding the function, and if so, how can I find a meaningful name for it? Or should I make a partial class Convert?
Any ideas?
Thanks in advance.
Update: In retrospect, my example was not very well chosen, as there exists a default conversion between enum and int. This would be a better example:
Person ConvertToPerson(const SpecialPersonsEnum e);