string str = (string)TypeDescriptor.CreateInstance(typeof(string), new object[] { "Hello World" });
public class Person { public string Name { get; set; } public int Age { get; set; } } Person p = (Person)TypeDescriptor.CreateInstance(typeof(Person), new object[] { }); p.Name = "Jane"; p.Age = 25;These examples use the System.ComponentModel namespace, indicating that the TypeDescriptor class is part of that library.