Unbox an Object to Its Type
<p>is there anyway to unbox an object to its real type? </p>

<p>Basically I am given an <code>ArrayList</code>, the array list are actually a list of <code>int</code> or <code>double</code>, or maybe other types ( it can be either, but it is either all <code>int</code> or <code>double</code>, no mix). Now, I will have to return a <code>List&lt;double&gt;</code> or <code>List&lt;int&gt;</code> or other list, depending on what is the real type. </p>

<pre><code>public List&lt;T&gt; ConvertToList&lt;T&gt;(ArrayList arr)
{
    var list1 = new List&lt;T&gt;();
    foreach(var obj in arr)
   {
     // how to do the conversion?
     var objT = ??
     list1.Add(objT);
    }
    return list1;
}
</code></pre>

<p>Any idea?</p>
