1
I want to handle a list in a method of another class and then return the treated list. I would like to know how to transfer this list to the other class.
I did it this way:
Main class:
DataTable result = new DataTable();
VerificaJuridico vj = new VerificaJuridico();
List<DataRow> rows = result.Rows.Cast<DataRow>().ToList();
List<DataRow> list = new List<DataRow>(result.Select());
vj.ChecaJuridico(list);
Second Class:
namespace Comunicacao
{
public class VerificaJuridico
{
public void ChecaJuridico<T>(List<T> lista)
{
foreach (var t in lista)
{
}
}
}
}
When running the program, the main class transfers the value, but the second class running the method brings nothing, what can it be? There’s something wrong with the transfer ?
What value
list
receives on this line:List<DataRow> list = new List<DataRow>(result.Select());
– Leonel Sanches da Silva
You should not pass the Rows variable in the method?
– PauloHDSousa
In reality they are fields of a datatable which I have transferred to a list, i.e., result is a datatable. The talk for List was ok, I just can’t get the list in the second class. It comes empty.
– Joelias Andrade
It is not empty already from the list?
– PauloHDSousa
Truth ... the first routine is empty... How could I transfer a query already in Datatable and transfer it to a List?
– Joelias Andrade
Where are you carrying the
result
?– Marco Souza
You’re using some database for that?
– Marco Souza