OutOfMemoryException when populating a <byte> list in C #
1 answer
Your loop never ends because it byteis an unsigned 8-bit integer with valid values from 0 to 255.
So, when the i == 255body of the cycle ends, another increment occurs. However, due to the range, bytethis does not cause iequal 256(it cannot!), Which, in turn, will lead to the completion of the cycle. Instead, it overflows and flips to 0. So the cycle continues (and again and again ...). This is a relatively common mistake when using unsigned counters.
, OOM. byte; int i .
+11