Im new to C# however im running into an issue when trying to pass the TableOne
type class into a method and use within the method itself.
Class:
public class TableOne
{
public List<string> CaseID { get; set; }
public List<string> Owner { get; set; }
public List<string> Assignee { get; set; }
public List<string> Comments { get; set; }
}
Method:
public static string ComposeHtmlTable<T>(Type classType, IList<T> table)
{
List<classType> test = table.Cast<classType>().ToList();
Console.WriteLine(test[0].CaseID[0]); // trying to access data
return "test";
}
How the method is being called:
ComposeHtmlTable<TableOne>(typeof(TableOne), data.TableOne);
Error im receiving:
'classType' is a variable but is used like a type.
The reason why its imperative that the method uses the parameter type is because there might be multiple types i.e. TableTwo
or TableThree
that I might pass into that method.
Any ideas on how I can tackle this?
TIA