title: Convert System.String generically to any complex type using "Convert.ChangeType()"
body: <p>I try to generically convert user input into either simple or complex types:</p>
  
  <pre><code>class Program
  {
    static void Main(string[] args)
    {
      Console.WriteLine("Welcome, please provide the following info... Confirm with &lt;RETURN&gt;!");
      Console.WriteLine();    
  
      Console.Write("Name (e.g. 'Peggy Sue'): ");
      var user = GetUserInput&lt;User&gt;(Console.ReadLine());
  
      Console.WriteLine();
      Console.WriteLine();
      Console.WriteLine("Hi {0}, nice to meet you!", user.Forename);
      Console.WriteLine();
  
      Console.Write("Age: ");
      user.Age = GetUserInput&lt;ushort&gt;(Console.ReadLine());
  
      Console.WriteLine();
      Console.WriteLine("Thanks and goodbye!");
      Console.WriteLine("Press &lt;RETURN&gt; to quit...");
      Console.ReadLine();
    }
  
    static T GetUserInput&lt;T&gt;(string data)
    {
      return (T) Convert.ChangeType(data, typeof (T));
    }
  }
  
  class User
  {
    public User(string name)
    {
      var splitted = name.Split(' ');
      Forename = splitted[0];
      Lastname = splitted[1];
    }
  
    public static implicit operator User (string value)
    {
      return new User(value);
    }
  
    public static explicit operator string (User value)
    {
      return string.Concat(value.Forename, " ", value.Lastname);
    }
  
    public string Forename { get; private set; }
    public string Lastname { get; private set; }
  
    public ushort Age { get; set; }
  }
  </code></pre>
  
  <p>For the conversion to my "User" class, I always get the exception "Invalid cast from 'System.String' to 'ConsoleApplication1.User'.". Does anyone know how to fix this?</p>
  
  <p>If I try something like this (not generically), it works just perfect:</p>
  
  <pre><code>Console.WriteLine((string) ((User) "Peggy Sue"));
  </code></pre>