Convert.ToString behaves differently for "NULL object" and "NULL string"
<p>I have foo (<code>object</code>) and foo2 (<code>string</code>) in  a C# console application. The Code 2 throws exception while Code 1 works fine.</p>

<p>Can you please explain why it is behaving so (with MSDN reference)?</p>

<p>// Code 1</p>

<pre><code>    object foo = null;
    string test = Convert.ToString(foo).Substring(0, Convert.ToString(foo).Length &gt;= 5 ? 5 : Convert.ToString(foo).Length);
</code></pre>

<p>// Code 2</p>

<pre><code>    string foo2 = null;
    string test2 = Convert.ToString(foo2).Substring(0, Convert.ToString(foo2).Length &gt;= 5 ? 5 : Convert.ToString(foo2).Length);
</code></pre>
