title: Cast string value to type Of T
body: <p>I have such kind of function:</p>
  
  <pre><code>Public Shared Function ResolveService(Of T As Class)() As T
              Return Container.Resolve(Of T)
  End Function
  </code></pre>
  
  <p>Normall way of passing object there is like:</p>
  
  <pre><code>Dim protocol = FactoryConnections.ResolveService(of Iftp)  /or Isftp...
  </code></pre>
  
  <p>However my value as string for instance Iftp is in string. How to case it in the place <code>(Of ...)</code> ?</p>
  
  <p>Tried so far using GetType/typeOf however no one seems to work:</p>
  
  <pre><code>Dim stringvalue as Type = Type.GetType("Iftp")
  Dim protocol = FactoryConnections.ResolveService(Of stringvalue)
  </code></pre>
  
  <p><strong>Note</strong> that i am calling that outside Factory class where that function comming from...
  It seems i cannot pass to place <code>(Of &lt;here&gt;)</code></p>