Hi All,
I've got a method that returns a List for a DataSet table
public static List<string> GetListFromDataTable(DataSet dataSet, string tableName, string rowName)
{
int count = dataSet.Tables[tableName].Rows.Count;
List<string> values = new List<string>();
// Loop through the table and row and add them into the array
for (int i = 0; i < count; i++)
{
values.Add(dataSet.Tables[tableName].Rows[i][rowName].ToString());
}
return values;
}
Is there a way I can dynamically set the datatype for the list and have this one method cater for all datatypes so I can specify upon calling this method that it should be a List<int
> or List<string>
or List<AnythingILike>
?
Also, what would the return type be when declaring the method?
Thanks in advance, Brett