Casting to object from a collection vs using foreach
<p>I am a little confused about the difference between the two statements.</p>

<p>This one works and prints out the property results just fine.</p>

<pre><code>foreach( string key in result.Properties.PropertyNames )
{
    foreach( object property in result.Properties[key] )
    {
         Console.WriteLine("{0}:{1}", key, property.ToString());
    }
}
</code></pre>

<p>and the following doesn't work. I thought by casting the specific property to object it would be the same thing but its obviously not:</p>

<pre><code>foreach( string key in result.Properties.PropertyNames )
{
     if( key == "name" )
     {             
         Console.WriteLine("{0}:{1}", key, ((object)(result.Properties[key])).ToString() );            
     }
}
</code></pre>

<p>I get the object type of <code>result.Properties[key]</code> printed instead.</p>
