Is there any plugin for VS or program to show type and value etc... of a C# code selection?
<p>What I want to do is be told the type, value (if there is one at compile-time) and other information (I do not know what I need now) of a selection of an expression.</p>

<p>For example, if I have an expression like </p>

<pre><code>int i = unchecked((short)0xFF);
</code></pre>

<p>selecting 0xFF will give me (Int32, 255), while selecting ((short)0xFF) will give me (Int16, 255), and selecting i will give me (Int32, 255).</p>

<p>Reason why I want such a feature is to be able to verify my assumptions. It's pretty easy to assume that 0xFF is a byte but it is actually an int. I could of course refer to the C# Language Specifications all the time, but I think it's inefficient to have to refer to it everytime I want to check something out. I could also use something like ANTLR but the learning curve is high.</p>

<p>I do intend to read the entire specs and learn ANTLR and about compilers, but that's for later. Right now I wish to have tools to help me get the job done quickly and accurately.</p>

<p>Another case in point:</p>

<pre><code>int? i = 0x10;
int? j = null;
int x;
x = (i &gt;&gt; 4) ?? -1;//x=1
x = (j &gt;&gt; 4) ?? -1;//x=-1
</code></pre>

<p>It may seem easy to you or even natural for the bottom two lines in the code above. (Maybe one should avoid code like these, but that's another story) However, what msdn says about the <a href="http://msdn.microsoft.com/en-us/library/ms173224.aspx" rel="nofollow">null-coalescing operator</a> is lacking information to tell me that the above code ((i>>4)??) is legal (yet it is, and it is). I had to dig into grammar in the specs to know what's happening:</p>

<ul>
<li>null-coalescing-expression</li>
<li>conditional-or-expression</li>
<li>conditional-and-expression</li>
<li>exclusive-or-expression</li>
<li>and-expression</li>
<li>equality-expression</li>
<li>relational-expression</li>
<li>shift-expression</li>
<li>shift-expression   right-shift   additive-expression
... (and more)</li>
</ul>

<p>Only after reading so much can I get a satisfactory confirmation that it is valid code and does what I think it does. There should be a much simpler way for the average programmer to verify (not about validity, but whether it behaves as thought or not, and also to satisfy my curiosity) such code without having to dive into <em>that</em> canonical manual. It doesn't necessary have to be a VS plugin. Any alternative that is intuitive to use will do just as well.</p>
