Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

11
  • 11
    Agreed. I'm having trouble seeing the purpose behind the more complex solutions, except maybe to be able to switch over the resulting "enum". Commented Dec 16, 2011 at 12:55
  • 2
    @fakeleft you cannot use a static class type with a generic type (template), and maybe other limitations, I think that is why people prefer the "more complex" solutions. Commented Nov 24, 2015 at 16:49
  • 3
    The constants need to be internal or public for this to work though Commented Nov 30, 2015 at 7:05
  • 86
    Static types cannot be used as parameters. Commented Nov 22, 2016 at 17:31
  • 10
    As @PedroMoreira points out, you can't pass GroupTypes as an argument type because it's a static class. That's the problem that Even Mien's answer solves. In this case you'd instead have to have void DoSomething(string groupType), which then means that groupType could have any string value whatsoever, even values that you aren't expecting, which means you have to be prepared for those invalid types and decide how to handle them (e.g. by throwing an exception). Even Mien's answer solves that by limiting the number of valid inputs to the options defined by the LogCategory class. Commented Jun 19, 2019 at 6:01