Ho un metodo che restituisce una lista per un tavolo DataSetTipo dinamico per l'elenco <T>?
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;
}
C'è un modo per impostare dinamicamente il tipo di dati per la lista e avere questo un metodo per tutti i tipi di dati di soddisfare in modo da poter specificare su chiamando questo metodo che dovrebbe essere un List<int
> o List<string>
o List<AnythingILike>
?
Inoltre, quale sarebbe il tipo di ritorno quando si dichiara il metodo?
Grazie in anticipo, Brett
Troppo semplice, grazie! – Brett