Lista ogólna jako parametr metody
Jak mogę użyć List<T>
jako parametru w metodzie, próbuję tej składni:
void Export(List<T> data, params string[] parameters){
}
Mam błąd kompilacji:
Nie można znaleźć typu lub przestrzeni nazw " T " (brakuje Ci dyrektywy używającej lub odniesienia do asemblera?)
56
3 answers
Aby wziąć generyczny List<T>
vs związany List<int>
musisz zrobić metodę generyczną. Odbywa się to poprzez dodanie parametru ogólnego do metody w taki sposób, w jaki dodajesz go do typu.
Spróbuj wykonać następujące czynności
void Export<T>(List<T> data, params string[] parameters) {
...
}
128
Author: JaredPar,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-01-02 11:59:14
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-01-02 11:59:14
Musisz zrobić metodę generyczną, jak również:
void Export<T>(List<T> data, params string[] parameters){
}
16
Author: Fredrik Mörk,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2009-10-27 21:10:27
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2009-10-27 21:10:27
public static List<T> pesquisa_lista<T>(string campo, string valor, List<T> lista)
{
return new List<T>();
}
6
Author: user3418564,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-03-14 05:59:31
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/doraprojects.net/template/agent.layouts/content.php on line 54
2014-03-14 05:59:31