Index was out of range exception when using list c# -
I am facing a problem here, and I need your help. I got the index with exception exception I was sorry for my bad english when I was out ...
The code is basically making the groundwork based on the area I have. The array is composed of 1 and 0, the so-called area occurs when you have a group of 1. And to decide whether this field is or not, using the differences, if [i] - [i - 1] = 0 then it is called initial, the position of a region and when the difference is -1, then this is a The end of the field is ... here is the code which got an exception
for (int i = 1; i & lt; histogrammatair.length - 1; i ++) {different = histogramwriter [ I] - Histogram-plaque [I-1]; If (different == 0 & amp; amp; amp;; and · histogramwriter [i] == 1) Area in the login area {region_देश [count_region] ++; If (state_value == true) {pos_awal.Add (i); State_awal = false; }} And if (different == -1) {pos_akhir.Add (i); Count_region ++; State_awal = true; } And if (i == histogramlatirir length - 1 & amp; amp; amp; amp; and & quot; == 0) {pos_akhir.Add (i); }} For (int i = 0; i & lt; pos_awal.Qount; i ++) {awalhuruf = pos_awal [i]; Lieberhurf = Poj_khiriir [ii] - Poj_val [ii]; Crop Crofurf = New Crop (New Rectangle (Ahal Hauruf - 5, 0, Leberhurf + 10, Image High.)); Curator Curcator = New Curator (Crawfurf.Apple (Image); ListCiriKarakter.Add (karakter.CiriKarakter); } It seems that I got an exception on this line
labelhuruf = pos_akhir [i] - pos_awal [i]; And when I check the count, it seems that pos_awal gets 4 count, and pos_akhir gets 3 digits and when it wants to decrease it is getting an exception Because there is no fourth poison '
and how can I understand this ...
Thanks in advance for you
It seems that the statements creating the lists do not include all the scenarios, whether different positive Be programmed? Can ((different == 0) & amp; amp; (histogram chart [i]! = 1 & amp; i! = Histogram title = 1] ? You always have an ' Else 'statement to ensure that any other scenario is included, but I can not tell that you need to add it to this list.
Comments
Post a Comment