Generic function issue - Cannot convert type 'System.Web.UI.Control' to 'T'
<p>It seems I still don't "get" generics ... I want a general function to load a user control which inherently calls Page.LoadControl() but I am getting the error above when trying to make it work.</p>

<p>Here is a mock up of the code I use to load the control:</p>

<pre><code>MyControl Ctrl = MyUtilClass.LoadControl(Page, "MyControl");
</code></pre>

<p>and then in MyUtilClass:</p>

<pre><code>internal static T LoadControl&lt;T&gt;(Page P, string ControlName)
{
    return (T)P.LoadControl(String.Format("~/{0}{1}.ascx", WebGlobals.cControlDir, ControlName));
}
</code></pre>

<p>I am obviously doing something wrong but my understanding was the compiler would look at the type of var I am trying to assign the result of this function to and be able to cast the result as that type.</p>
