Has anyone got a good bit of code to turn a string into a given type in a type-safe manner

i.e.

VB Code:
  1. Public Shared Function FromString(Of TReturn)(ByVal stringValue As String) As TReturn
  2.  
  3.         If (String.IsNullOrWhiteSpace(stringValue)) Then
  4.             If GetType(TReturn).IsPrimitive Then
  5.                 'get the default
  6.  
  7.             Else
  8.                 Return Nothing
  9.             End If
  10.         Else
  11.             If GetType(TReturn).IsPrimitive Then
  12.  
  13.  
  14.             Else
  15.  
  16.  
  17.             End If
  18.         End If
  19.  
  20.  
  21.     End Function

Anyone got some good ideas on filling in those blanks?