I've been working the project mentioned c-sharp-compilerresults-generateinmemory.
I've been writing a lot of code to get my "class discovery" implemented. It works cool, but I realized it would be a lot more efficient if I implemented everything as an derived class of `System.Reflection.Assembly'.
So with that new derived class written I hit a problem. When I try to assign the base class to the new derived class it throws an error, just the normal did you miss an explicit cast
error.
I thought C# did implicit casting for extended types?
So I have some source code like this...
Assembly asm = MyCompilerResults.CompiledAssembly(); /* this works */
Interface asmInterface = new Interface();
asmInterface = asm; /* bad */
asmInterface = (Interface)asm; /* bad */
public class Interface : Assembly {
public Interface() {} // I always just declare the empty constructor.
public void Helpermethod1() {}
public void Helpermethod2() {}
public void Helpermethod3() {}
};
So as it's only the second week I've been writing C# I have to ask...
How do I add the base class to my class?
The question here... Why can't I write an implicit operator from a Base class to a Derived class in C#?
This seems to indicate my casting should work unless I'm misunderstanding the answers.