tags:

views:

322

answers:

2

How can I use a List as a parameter on a method, I try this syntax :

void Export(List<T> data, params string[] parameters){

}

I got compilation error :

Error   34 The type or namespace name 'T' could not be found (are you missing a using directive or an assembly reference?) D:\Resocentro\Proyectos\SRA\SRA.Data\Model\ETLPackague\IETLPackage.cs 15 28 SRA.Data

Thanks,

+13  A: 

To take a generic List<T> vs a bound List<int> you need to make the method generic as well. This is done by adding a generic parameter to the method much in the way you add it to a type.

Try the following

void Export<T>(List<T>data, params string[] parameters) {
 ...
}
JaredPar
+5  A: 

You need to make the method generic as well:

void Export<T>(List<T> data, params string[] parameters){

}
Fredrik Mörk