Doubts regarding the use of lists in c#

Asked

Viewed 27 times

0

In my list there are 4 items with code 711, however I just want to get an item inside that list, is there a better way to do this? Because when I fill in my append, it writes the data of the 4 and not only of 1 item of that same list. The correct would be to fill in this way: O correto era para vir assim

inserir a descrição da imagem aqui

Code:

foreach (Movimentacao mov in listaMovimentacao)
            {
                foreach (ItemMovimento dadosItensMov in listaItemMovimentacao.Where(o => o.Movimentacao.Codigo == mov.Codigo).OrderBy(o => o.Movimentacao.ContratoOperCred.Codigo))
                {

                    strConstrution.Append(string.Format(dadosDetalhamentos, dadosItensMov.Movimentacao.ContratoOperCred.Codigo + " " + dadosItensMov.Movimentacao.OperacaoCredito.DescricaoOperacaoCredito,
                                            dadosItensMov.ValorMovimentoMC.ToString("N2"), sumJuros.ToString("N2"), sumEncargos.ToString("N2"), dadosItensMov.Movimentacao.ValorTotalMovimentoMC.ToString("N2")));

                }

            }
  • Don’t get it, you want to bring only one record per code? or only the 711?

  • Of the index 0 to 3 that appears in the list all have the code 711, however I only want to get the index 2.

  • @Leandroangelo there is a way to do?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.