I have a class that is awaiting the creation of IWorkspace :
public class MyClass { protected IWorkspace workspace; public MyClass(IWorkspace w) { this.workspace = w; } }
and Derived derived class. In this derived class, I have copy-constrcutor that should create a Derived instance based on the MyClass instance.
public class Derived : MyClass{ public Derived(MyClass m) : base(m.workspace) { } }
The above will not compile with the following error:
Unable to access protected member MyClass.workspace 'through qualifier of type MyClass; qualifier must be of type Derived (or derived from it)
So what I'm trying to achieve is copying the members of the base class into a derived one and creating the latter in a new instance. The reason I don't use the constructor for IWorkspace in my derived class is because I do not have access to such a workspace inside the client code, only for the MyClass instance to copy.
source share