Geeks With Blogs
John Conwell: aka Turbo Research in the visual exploration of data
For grins I looked at my code that calls:

T tmp = new T();

in Reflector, so see if it could shed any light into T instance creation badness.  Well, it turns out that the C# compiler spits out code to call Activator.CreateInstance

T tmp = Activator.CreateInstance<T>();

I kind of get why the C# compiler does this, because it doesnt know what T is at compile time.  But at run time the JIT compiler DOES know.  I'm surprised that the C# team didn't build in the smarts to JIT code to explicitly call the default constructor of whatever type T is. Posted on Friday, June 13, 2008 12:30 PM | Back to top


Comments on this post: Creating an instance of a generic paremeter is slooooo: part deux

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © John Conwell | Powered by: GeeksWithBlogs.net