Apologies if this has been answered before, but I've been reading and searching and I can't find the answer.
I have an array, let's say string[] myColors = {"red","white","blue"};
and I have selected one of those colors, e.g. by accessing the nth member of the array: myColors[2]
which would be the string "blue".
Separately, I have a class, box, of which I have created an instance, myBox. The class has a property, boxColor, of type Color. And the possible values of that Color type include Color.red = RGB(255,0,0), Color.white = RGB(255,255,255), and Color.blue = RGB(0,0,255) (although for the sake of the argument, the actual values and types of these enumerated values are irrelevant, they could equally be float
's or any other C# type).
How would I go about setting the myBox.boxColor to the value that I get from myColors[2]
?
i.e. something like myBox.boxColor = (Color) (value of the string myColors[2]);
In this case, so that I can actually draw on the screen in that particular color.