I\'m adding some bindable CLR properties to my ongoing WPF application in my App class and I can\'t compile because of this inconsistent accessibility error.
Don't know about vb, but in c# classes defaultly have as restrictive modifiers as possible, which means - they are internal
, unless they are nested within another class - in that case they are private
.
Here's a complete guide (-:
While it's generally considered good practice to be explicit in all access modifiers, it's not unreasonable to allow them to be omitted with some sort of default.
Of course that default has to be sensible. If the default was public and it was used inappropriately then there would be no way to statically determine it was a mistake (unless it exposed a type that is elsewhere defined with less access), code could go for months or years before someone noticed the flaw, and then fixing it would be a breaking change to the assembly.
Because the default is private where applicable and internal in all other cases, then if this is a mistake it'll result in a compiler error (as something needs it to have greater access) which is caught easily, or in a class simply not being visible to other assemblies (easily caught, especially with most IDEs).
Restrictive defaults are therefore the obvious way to go.
Things declared outside of a class or struct will default to internal. Things declared inside of a class or struct will default to private. refer http://msdn.microsoft.com/en-us/library/ba0a1yw2(VS.80).aspx