1
Assuming I have one List<byte[]> Imagens;
and I want to know if any element on that list has more than 1 mega, I could do it via foreach
, checking item by item:
foreach (var item in Imagens)
if (item.Length > 1000000)
throw new ArgumentException(msn);
What would be the way to do that?
The list must be invalid if any of its elements is more than 1MB.
I should never make an exception to this. And I would need to explain the criterion better. Just 1 be out of this specification and should close the algorithm always? And the object is a array of bytes the amount of elements in essence is the same as the amount bytes.
obter o tamanho total da lista em bytes, assim através de uma simples divisão saberia-se se a Lista contem elementos maiores que 1 mega
. Is it? Why? No image, of course, is less than 1MB?– Maniero
I will modify the question and let it more direct, but I will not expose here in what context this will be used because I believe that is not the focus, I believe that this would be more suitable for Codereview.
– Matheus Saraiva
@Matheussaraiva provide the context of the question, can help to find a better solution to your problem.
– gato