CreateInstance

  • Thread starter Thread starter Bud J via DotNetMonster.com
  • Start date Start date
B

Bud J via DotNetMonster.com

How expensive is CreateInstance for example.....

ISomeInterface isomeType = Activator.CreateInstance(someType) as
ISomeInterace;
and if it is not that expensive is there anything to watch out for if i use
it
 
Bud J via DotNetMonster.com said:
How expensive is CreateInstance for example.....

ISomeInterface isomeType = Activator.CreateInstance(someType) as
ISomeInterace;
and if it is not that expensive is there anything to watch out for if i use
it

Well, how often are you intending to call it? It's expensive compared
with direct instantiation, but I doubt that it'll be the performance
bottleneck unless you call it in a very tight loop which is executed
millions of times.
 
Not executed that often at all. I prefer to use direct but just haven't
figured the way since i don't know the class until runtime. thanks for the
info
 
Back
Top