title: c# how to implement type converter
body: <p>I am struggling to implement a simple Type converter in C#. 
  I followed this guide <a href="https://msdn.microsoft.com/en-us/library/ayybcxe5.aspx" rel="noreferrer">https://msdn.microsoft.com/en-us/library/ayybcxe5.aspx</a></p>
  
  <p>Here is my class :</p>
  
  <pre><code>public class TestClass: TypeConverter
  {
          public string Property1{ get; set; }
          public int Property2 { get; set; }
          public TestClass(string p1, int p2)
          {
              Property1= p1;
              Property2 = p2;
          }
          public override bool CanConvertFrom(ITypeDescriptorContext context,
          Type sourceType)
          {
              if (sourceType == typeof(string)) {
                   return true;
              }
              return base.CanConvertFrom(context, sourceType);
          }
          public override object ConvertFrom(ITypeDescriptorContext context,
           CultureInfo culture, object value)
          {
                if (value is string) {
                      return new TestClass ("", Int32.Parse(value.ToString()));
                }
                return base.ConvertFrom(context, culture, value);
          }
          public override object ConvertTo(ITypeDescriptorContext context,
          CultureInfo culture, object value, Type destinationType)
          {
              if (destinationType == typeof(string)) {
                 return "___"
              }
              return base.ConvertTo(context, culture, value, destinationType);
          }
   }
  </code></pre>
  
  <p>I do the following <code>TestClass ("", Int32.Parse(value.ToString()));</code> as for now I am only interested in such case as <code>"1231" -&gt; new TestClass("", 1231)</code></p>
  
  <p>And here goes the code that gives me an exception;</p>
  
  <pre><code>TypeConverter converter=TypeDescriptor.GetConverter( typeof(TestClass));
  Object lalala = converter.ConvertFromString("234");
  </code></pre>
  
  <p>This code throws <code>NotSupportedException</code> but I don't get why</p>