lundi 4 septembre 2017

C# Reflection creating constructor with parameters at runtime

How can I define a constructor with parameters using reflection? I've been reading and reached the part when you use Emit with opcodes, but to be honest I don't understand anything from what is written.

I'm reading this article: http://ift.tt/1a7JfMy

In the mentioned article, it used a default constructor with this line(49): typeBuilder.DefineDefaultConstructor(MethodAttributes.Public | MethodAttributes.SpecialName | MethodAttributes.RTSpecialName);

But I want a constructor that will initialize the object with some parameters, is that possible? if yes, could you provide a short example? thanks





Aucun commentaire:

Enregistrer un commentaire