views:

387

answers:

2

And why would I use one over the other in my code?

+1  A: 

According to this blog post by Vance Morrison, RuntimeTypeHandle is a value type (struct) that wraps an unmanaged pointer, so Type.GetTypeHandle(obj).Equals(anotherHandle) is faster to use for strict "is exactly the same type" comparisons than obj.GetType().Equals(anotherType) -- the latter creates System.Type instances which are, apparently, heavier.

However, it's also less obvious, and definitely falls under the category "micro-optimization" so if you're wondering when you need one over the other, you should probably just use System.Type.

Rytmis
A: 

In .NET 4.0 Beta 1 RuntimeTypeHandle just wraps RuntimeType. It seems all benefits of using it as a cheap Type proxy has gone.

OmariO