Activator.CreateInstance and beyond

Q: Assume we have 2000 unknown types; (however) we know each type has a constructor with integer as its’ only parameter type. How to create objects 10000 times for each type (and make such late-new fast)? Activator.CreateInstance comes to my fingers first. It is just so convenient to use: calling Activator.CreateInstance(type, new object[] {100}) in…

12

LateNew source

The following code is for the post “Activator.CreateInstance and beyond“ **All source code is provided as is, with no warranties intended or implied. Use at your own risk.**Instruction perl sample.pl > sample.cs csc /t:library sample.cs csc /o+ latenew.cs To run: latenew sample.dll 1000 1000 sample.plfor $i (1..2000) { $name = “C$i”; print “public class $name…

0