0

Enums are making some of my assemblies not-CLS-compliant.

I know they shouldn't be public because every language defines them differently.

But if I cannot hide them and use them internally, what can I use instead of an enum?

Maurice Klimek
  • 930
  • 5
  • 13
  • 48
  • 1
    a static class with constant fields – J.Salas Apr 07 '22 at 12:25
  • 1
    Numbers, enums are just fancy names for numbers, in C# enums are by default just an `int`, meaning you can do things like `ConsoleColor.Black == (ConsoleColor) 0` (which will be true) – MindSwipe Apr 07 '22 at 12:26
  • From [here](https://stackoverflow.com/questions/33100991/use-of-enum-is-not-cls-compliant): *"This is happening because you are publicly exposing from an assembly marked as CLS-Compliant a type that is from an assembly that is not CLS-Compliant. Note that you are allowed to consume a type that is not CLS-Compliant in a CLS-Compliant assembly; but you are not allowed to expose such a type."* – Robert Harvey Apr 07 '22 at 12:27
  • @RobertHarvey Although I've seen that question. I don't think my question is a duplicate for it. Also, it is an extension, more professional one, of what I wrote in the second sentence :-) But not answering the question. Just explaining the logic. I respect your decision, though. – Maurice Klimek Apr 07 '22 at 12:57

0 Answers0