mardi 25 décembre 2018

How to instantiate an int using Activator.CreateInstance?

Usually when using Activator.CreateInstance() you pass the type from which to instantiate an object, and parameters to send to the constructor.

However, It is not possible to write something like this: int n = new int(5), so it is also not possible to write Activator.CreateInstance(typeof(System.Int32), 5). So how to go about this?





Aucun commentaire:

Enregistrer un commentaire