Is there a way to do something like this?
Public Enum CarMakes
Honda
BMW
Mazda
Friend Yugo
End Enum
I need to expose the the Enum to Public except for one of the items I just want to be available from inside the assembly.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
This is not possible to do. Individual enum values don’t have the concept of accessibility but instead just have the accessibility of the declaring enum.
Note: Even if they did have accessibility it would be very easy for the caller to violate it. Enum values are not checked for correctness. Hence even if the above syntax was legal I could subvert it in the following way.
This will compile and run without any errors and produce verifiable IL.