title: C# convert string to class that has a constructor with string parameter
body: <p>I have seen examples on how to convert string to class type, but I was unable to apply the same logic to a class that has a constructor, which itself takes a string as a parameter. This is what I have seen on other posts.</p>
  
  <pre><code>Type type = Type.GetType("classNameAsString");
  object instance = Activator.CreateInstance(type);
  </code></pre>
  
  <p>What I want to do is to apply the same to this case</p>
  
  <pre><code>public class ExampleClass
  {
      public ExampleClass(string strParameter)
      {
      }
  }
  </code></pre>
  
  <p>I would normally instantiate ExampleClass as</p>
  
  <pre><code>var exClassInst = new ExampleClass("stringParam");
  </code></pre>
  
  <p>How can I achieve the same, but first converting "ExampleClass" string to type and then instantiating it. Thank you for your help.</p>