Right now I create following arrays (on Button_click event):
string[,] Butt = new string[2, 3] {
{ "120", "200", "#ffc90e" },
{ "380", "200", "#22b14c" }
};
int[,] arrat = new int[,] {
{ 199, 199 },
{ 257, 189 },
{ 407, 185 },
{ 521, 196 },
{ 608, 232 },
{ 620, 300 },
{ 509, 338 },
{ 386, 344 },
{ 288, 347 }
};
I want to optimize my code so I don’t have to crete new arrays each time. Better solution will be – to load arrays from file on program launch
lets say I have a CSV file with following content:
199, 199
257, 189
407, 185
521, 196
how do I load everything into an array: “int[,] array = new int[,]” ??
You should put some error checking but you may start from:
Helper method for conversion (instead you may want to embed in the
Parse()method):(I’m not using LINQ ’cause I guess you should put a lot of error checking inside that methods to validate input data).