i read here how to create anonymous types at runtime in c#
AssemblyBuilder dynamicAssembly =
AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName("MyDynamicAssembly"),
AssemblyBuilderAccess.Run);
string propertyName = "prp_1";
//Type propertyType = new Type();
ModuleBuilder dynamicModule = dynamicAssembly.DefineDynamicModule("MyDynamicAssemblyModule");
TypeBuilder dynamicType = dynamicModule.DefineType("MyDynamicType", TypeAttributes.Public);
PropertyBuilder property =
dynamicType.DefineProperty(
propertyName,
System.Reflection.PropertyAttributes.None,
propertyType, // idk what to put here?
new[] { propertyType } // and here ?
);
//call this first
AddProperty(dynamicType, propertyName, propertyType );
//then we ' ll dynamic type
Type myType = dynamicType.CreateType();
function that is called
public static void AddProperty(TypeBuilder typeBuilder, string propertyName, Type propertyType)
there is propertyType in the code i dont know what to put there. can i make
type mytype = \\typefree?
thank you.