I am trying to make a function where I either pass a class name or an empty object and then build a new one and add it to a list. I have tried a few different ways that I've found online but it doesn't seem to work for passing as a function or making the object, not both and none for the list.
class Program
{
static void Main(string[] args)
{
Read("TestObject");
}
static void Read(string classname)
{
List<Object> listObject = new List<object>(); //Not sure what to do
typeOf(classname) n = new typeOf(classname)(); //Not sure what to do
listObject.Add(n);
}
}
public class TestObject
{
public string Col1 { get; set; }
public string Col2 { get; set; }
}