This may not be the finest solution in the world, but you can try to trick the compiler by assigning values ββto an enumeration, and then starting internal calls. For example, this application starts:
namespace ConsoleApplication { class Program { static void Main(string[] args) { TestMethod((Choices)3); } private static int TestMethod(Choices choice) { return 1; } } public enum Choices { One = 1, Two = 2, [ObsoleteAttribute("don't use me", true)] Three = 3, Four = 4 } }
I thought Enum.Parse would work, but it gets an error at runtime, so don't do this:
(Choices)Enum.Parse(typeof(Choices), "Choices.Three")
I have no experience with legacy enumerations, so I would recommend a bit of good testing around this.
source share