title: Generic methode vs cast
body: <p>I have a methode searching for a winform control by name. My first approche was to do it like that</p>
  
  <pre><code>private Control SearchControlByName(Control parent, string name){recursive search...}
  </code></pre>
  
  <p>Calling the methode looks like</p>
  
  <pre><code>Label temp = (Label)SearchControlByName(panel1, "label4");
  </code></pre>
  
  <p>Then a thought to myself it would be better do do it with an generic methode like this</p>
  
  <pre><code>private T SearchControlByName&lt;T&gt;(Control parent, string name) where T : Control {recursive search}
  </code></pre>
  
  <p>calling like</p>
  
  <pre><code>Label temp = SearchControlByName&lt;Label&gt;(panel1, "label4");
  </code></pre>
  
  <p>And now I'm not sure which is the better approach. What are the advantages / drawbacks of the generic method vs casting after calling the method?
  In the generic methode I also have to cast the result like this</p>
  
  <pre><code>return (T)result
  </code></pre>