Theme:
Verificar todos se todos os items são iguais
Eu preciso verificar se todos os itens são iguais de uma lista para uma certa propriedade usando a linguagem c#
Date: Wednesday, February 1, 2023
1 answers |
433 view(s)
by Mauricio Junior
Answers
Você pode usar o .All e verificar com o primeiro código, veja o exemplo de código.
//check all items are the same of the first //add the first to the tagcode if (order.Items.All(x => x == order.Items.FirstOrDefault())) { header.TagCode = order.Items.FirstOrDefault().TagCode; }
Espero ter ajudado. ecode10.com
Wednesday, February 1, 2023
Mauricio Junior
![25](https://ecode10-image.s3.amazonaws.com/anuncios/f312b8a3-31b7-4370-8017-077c77999f53c-sharp-basico-na-pratica.png)