convert Dictionary to array
Code:
// declare child arrays
public string[,] childcolor;
public string[,] childgeneo;
// create dictionaries
public Dictionary<string, int> colors = new Dictionary<string, int>();
public string color; // name for dictionary
public Dictionary<string, string> geneo = new Dictionary<string, string>();
public string gtype; // name for dictionary
var jw = new hk1Class();
public static void child_calc()
{
// convert dictionaries to child arrays
jw.childcolor[,] arr = new jw.colors[jw.color.Count];
jw.color.Values.ToArray();
jw.childgeneo[,] arr = new jw.geneo[jw.gtype.Count];
jw.gtype.Values.ToArray();
int z = 0;
while (z < (jw.totalcount + 1))
{
// calculate color type %
int colorpct = ((jw.childcolor[z, 1] / jw.totalcount) * 100);
colorpct += "%"; // appedn to string
Console.WriteLine("{0}, {1}, {2}, {3}",
jw.childcolor[z, 0],
jw.childgeneo[z, 0],
jw.childcolor[z, 1],
colorpct);
} // end while
} // end if
return;
} // end child_calc
I'm getting "field' is used like a 'type' error on jw.childcolor which causes other parts to error out.
How do I fix this & why am I getting the error?
I want to convert the dictionaries to arrays to read & write sequentially.