-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;
}
1
  • What is tableName, is it the fully qualified namespace of a custom class? Commented Sep 22, 2014 at 13:59

1 Answer 1

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");
Sign up to request clarification or add additional context in comments.

1 Comment

If type is outside the current assembly or mscorlib, you need Assembly.Qualified.Type.Name.There

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.