O'Reilly logo

From Java to C#: A Developer's Guide by Heng Ngee Mok

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

16.6. Creating new types during runtime

System.Reflection.Emit contains classes such as AssemblyBuilder, ModuleBuilder, TypeBuilder, and MethodBuilder which are used to create new types during runtime. Rarely used in conventional programming, the ability to create new Types during runtime may be useful when you want to dynamically create new proxy classes for remote operations.

Since this is an advanced topic, I will give only a simple code example to give a clue as to which classes to use. Refer to the API documentation for more information about each class in System.Reflection.Emit.

 1: using System; 2: using System.Reflection; 3: using System.Reflection.Emit; 4: 5: public class TestClass{ 6: 7: public static Type CreateType (){ 8: 9: AppDomain ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required