Hi... I have following requirement:
Suppose there are 2 classe:
Class A
{
public void method1()
{
}
public void method2()
{
}
}
Class B
{
public void method3()
{
}
public void method4()
{
}
}
Now I want to create another class C having all the methods of Class A & Class B. Assume that there are no member fields in A & B & no two methods have same name. Can class C be generated Inmemory ?
Actually I will have info regarding Classes A, B etc in an XML & need to combine them into a single class so that all the methods can be accessed by a common prefix, i.e., like C.Method1() ...
Any help will be appreciated !
Loading
Mike GoldPosted Aug 5, 2007, 5:04 PM
The short answer is yes. You can use CodeDom to create and compile an assembly with your new class. You can use reflection to instantiate your new class.
Check out these articles to help you:
http://www.c-sharpcorner.com/UploadFile/mgold/CodeDomCalculator08082005003253AM/CodeDomCalculator.aspx
http://www.codeproject.com/useritems/DynamicCodeGeneration.asp