I've initialized a 2 dimensional array and starting from index 5 onwards contain null value. I'm trying to add the array values to my Chart Control. When I try displaying the values to Console.WriteLine, there's no exception occurred however when I add to my chart series, the exception is "Index was outside the bounds of the array." Anyone can help me? is it because chart control has limited bars?
try
{
//females age range
string[,] gAge = new string[10, 2];
gAge[0, 0] = "F.13-17";
gAge[0, 1] = yf.f1317.ToString();
gAge[1, 0] = "F.18-24";
gAge[1, 1] = yf.f1824.ToString();
gAge[2, 0] = "M.25-34";
gAge[2, 1] = yf.m2534.ToString();
gAge[3, 0] = "M.13-17";
gAge[3, 1] = yf.m1317.ToString();
gAge[4, 0] = "M.18-24";
gAge[4, 1] = yf.m1824.ToString();
for (int i = 0; i < gAge.Length; i++)
{
if (gAge[i, 0] == null)
{
break;
}
else
{
Console.WriteLine(gAge[i, 0].ToString());
string[] seriesArray = { gAge[i, 0].ToString() };
Series series = this.chart1.Series.Add(seriesArray[i]);
}
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}