I have t his code in the scroll bar event:
if (_fi.Length > 0)
{
myTrackPanelss1.trackBar1.Minimum = 0;
myTrackPanelss1.trackBar1.Maximum = _fi.Length - 1;
tt = list_of_histograms[myTrackPanelss1.trackBar1.Value];
HistogramGraphs1.DrawHistogram(tt);
long res = GetTopLumAmount(tt, 1000);
long max = GetHistogramMaximum(tt);
GetHistogramAverage(tt);
setpicture(myTrackPanelss1.trackBar1.Value);
this.pictureBox1.Refresh();
}
With the following variables defined:
_fi = FileInfo[]
tt = long[]
list_of_histograms = List<long[]>
When i move the bar to the end to the right it's getting to frame 1047 and then throw the exception. When the exception is thrown i see that :
_fi.Length = 1049
(-1 so its 1048) so if its starting from 0 its like 0 to 1047)
list_of_histograms.Count = 1048
myTrackPanelss1.trackBar1.Value = 1048
I know what the exception means the question is why it happend if i,m doing _fi.Length - 1
as length ?