NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

Compiler Error CS1540

Cannot access protected member 'member' via a qualifier of type 'type1'; the qualifier must be of type 'type2' (or derived from it)

Although a derived class can access protected members of its base class, it cannot do so through an instance of the base class.

The following sample generates CS1540:

public class Base {
   protected void func() {
   }
}

public class Derived : Base {
   public static void test(Base anotherInstance) {
   // the method declaration could be changed as follows
   // public static void test(Derived anotherInstance) {
      anotherInstance.func();   // CS1540
   }
}

public class Tester : Derived {
   public static void Main() {
      Base pBase = new Base();
      // the allocation could be changed as follows 
      // Derived pBase = new Derived();
      test(pBase);
   }
}