ForEach em Listlt;gt;
Olá amigos, alguém poderia me dizer um exemplo de código ForEach em uma List<>?
Obrigado,
Alexei.
Obrigado,
Alexei.
Buenolex
Curtidas 0
Respostas
Codename.v
06/11/2008
Segue o código!
Sem mais... 8)
Abraços!
//Cria uma nova generic list de string.
List<string> lstString = new List<string>();
//Insere cem valores no list.
for(int count = 0; count < 100; count++)
{
lstString.Add("Valor " + count.ToString());
}
//Percorre a list usando foreach e exibe o valores na tela.
foreach(string str in lstString)
{
Console.WriteLine(str);
}
Sem mais... 8)
Abraços!
GOSTEI 0
Proglele
06/11/2008
Voce pode fazer assim:
Types.Categoria oCategoria = new Types.Categoria();
BLL.Categoria objCategoria = new BLL.Categoria();
objCategoria.SelecionarCategorias().
ForEach(delegate (Types.Categoria newObjCategoria)
{
// faz alguma coisa com alista.
}
Types.Categoria oCategoria = new Types.Categoria();
BLL.Categoria objCategoria = new BLL.Categoria();
objCategoria.SelecionarCategorias().
ForEach(delegate (Types.Categoria newObjCategoria)
{
// faz alguma coisa com alista.
}
GOSTEI 0
Ricardo Silva
06/11/2008
Rapaizzzzz.....
GOSTEI 0