Am 07.10.2010 02:40, schrieb Thomas Scheidegger:
> ?Hi Armin
>
>> Dim o As New Class1
>> o.var = 2 'ERROR: not accessible becaus Protected
>> IMO, the error is not ok.
>
> IMHO it's OK, read:
>
> http://msdn.microsoft.com/en-us/library/e8zxe4y5.aspx
> Protected...
> "You can read or write to the variable from anywhere within the class,
> as well as from _WITHIN_ any class derived from it,
> but not from _OUTSIDE_ any class in the derivation chain.
Class2 is _IN_ the derivation chain. It inherits from Class1.
See also:
http://msdn.microsoft.com/en-us/library/76453kax.aspx
"....can be accessed only from within the same class, or from a class
derived from this class"
The condition is clearly met.
> and C#:
> http://msdn.microsoft.com/en-us/library/bcd5672a.aspx
> "A protected member of a base class is accessible in a derived class
> only if the access occurs through the derived class type"
The access occurs through Class2. Class2 is a derived type.
As I said, the only difference is the kind of reference used.
That this kind makes the distinction isn't mentioned anywhere.
I can't take it from your links either.
--
Armin