-1

I have code like below. It used read user input as table name then get the class property info base on the input as class type. The issue is typeof(tableName) is not correct. Anybody can help me out will be great appreciated.

void Main()
{
    var tableName = Console.ReadLine();

    var propertyInfo = this.GetTableProperties(tableName);
}

public PropertyInfo[] GetTableProperties(string tableName)
{
    PropertyInfo[] props = typeof(tableName).GetProperties();
    return props;
}
Selman Genç
  • 100,147
  • 13
  • 119
  • 184
D i D
  • 9
  • 3

1 Answers1

0

Type.GetType can provide a type based on a string, but requires the fully-qualified name:

Type t = Type.GetType("Fully.Qualified.Type.Name.Here");
David Crowell
  • 3,711
  • 21
  • 28