I just want to understand why I cannot create a protected enum on C#?
The compiler refuses to accept that
Does anyone know why that may be?
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.
You can have a protected type which is nested within another type – and that includes enums:
However, it doesn’t make sense to make a non-nested type protected – the protected modifier is about granting access to a member from within a derived type; as a top level type is only a member of a namespace rather than another type, there’s no type you could derive from to get the extra access.
Could you describe what you’re actually trying to achieve, and then we could try to work out what the most appropriate visibility would be?