Note that there are some explanatory texts on larger screens.

plurals
  1. POWhat is Type.GUID and how does it relate to Type.Equals()?
    text
    copied!<p>I came across some interesting behavior while trying to compare an instance of <code>System.RuntimeType</code> with a generic type <code>TOut</code>:</p> <pre><code>Type runtimeT = methodInfo.ReturnType; // get RuntimeType using reflection Type genericT = typeof(TOut); // This condition fails because runtimeT doesn't // seem to include an assembly qualified name if(runtimeT.Equals(genericT)) { ... } </code></pre> <p>Here is my evidence:</p> <p><img src="https://i.stack.imgur.com/udc4n.png" alt=" screenshot of debug watch window - Equals() returns false on types, true on GUIDs "></p> <p><strong>Disclaimer:</strong> I don't know precisely what a GUID is in the context of the CLR / type-system, except of course that the acronym stands for <em>global unique identifier</em>. Perhaps the name is misleading me.</p> <p><strong>Assumption:</strong> I'm assuming here that a<code>Type</code> GUID uniquely identifies the fully qualified type, including the<a href="http://msdn.microsoft.com/en-us/library/system.type.assemblyqualifiedname.aspx" rel="nofollow noreferrer"><code>AssemblyQualifiedName</code></a> that's missing from <code>factoryInfo.ReturnType</code> in the screenshot (the <code>null</code> value.) </p> <p>Is my assumption wrong?</p> <ul> <li><p><em>Yes:</em> What does type GUID truly represent, and how is it used? </p></li> <li><p><em>No:</em> Why wouldn't <a href="http://msdn.microsoft.com/en-us/library/3ahwab82.aspx" rel="nofollow noreferrer"><code>Equals()</code></a> be implemented by comparing GUID?</p></li> </ul>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload