Today I learned something new which I was not aware of.
I was reading the Peter's blog post regarding limited access of protected constructor. According to the new c# specification , protected constructor cannot be accessed through base class rather it is accessible through instance of derived class. This is a marked change in VS2005 ( not followed in VS2003 ). Protected instance constructors follow the same rule as the protected instance members. They are accessible only through instance of derived class.
Protected static members can be accessed from base class as well as derived class. There is no need to create the instance. So protected static member are accessible in same way as public static members are. So to avoid confusion, static members can be declared as private, public and internal rather then protected. Declaring them as protected would hardly make any difference when compared to public static declaration.
Tags : C# , CSharp , DotNet , VS2005 , Programming, Protected Constructors, Constructors
Saturday, January 06, 2007
C# - Protected Access for Instance Members
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment