Link to home
Start Free TrialLog in
Avatar of brdrok
brdrok

asked on

Q about Accessibility

Hello,

perhaps a dumb questioni but I am curious as to why I am not getting a "Inconsistent Accessibility" error or at least a warning.  For example, if I had a class like the following:

internal class Person
{
    //properties
    public string FirstName
   {
         get { ............. }
         set { ............ }
   }
}

My property has a greater accessibility level than my class declaration.  I am surprised that it compiles w/o an error or warning.

thanks
ASKER CERTIFIED SOLUTION
Avatar of Nico
Nico
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Also it might be helpful to read chapter 3.5 of the C# language specification, which describes exactly how this stuff works :)
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of brdrok
brdrok

ASKER

thanks for the comments.  I was thinking it's odd that public properties is legal even though the class has been declared as internal.  But it has to be that way if for no other reason that should an internal class implement some kind of interface it wouldn't be able to if an internal class couldn't expose any public members, methods, etc.