Hi,
I have this piece of code:
But when I try to build it, I get these 2 errors:
on these 2 lines:
But above the while loop, I declared the vars, so I thought the vars should exists.
Why am I getting this error?
I have this piece of code:
C#:
int[] values;
string[] legends;
int i = 0;
while(reader.Read())
{
values[i] = Convert.ToInt32(reader.GetValue(reader.GetOrdinal("total_played")));
legends[i] = reader.GetValue(reader.GetOrdinal("history_artist")) + " - " + reader.GetValue(reader.GetOrdinal("history_title"));
}
chart.SetValues(values);
chart.SetLegends(legends);
chart.Render("Most played songs", "", 200, 200);
System.Drawing.Image final = chart.Final;
graphMostPlayed.Image = final;
But when I try to build it, I get these 2 errors:
Error 1 Use of unassigned local variable 'values' C:\Documents and Settings\Lucas\My Documents\Visual Studio 2005\Projects\RM\RM\Form1.cs 730 23 RM
Error 2 Use of unassigned local variable 'legends' C:\Documents and Settings\Lucas\My Documents\Visual Studio 2005\Projects\RM\RM\Form1.cs 731 24 RM
on these 2 lines:
C#:
chart.SetValues(values);
chart.SetLegends(legends);
But above the while loop, I declared the vars, so I thought the vars should exists.
Why am I getting this error?