With below code, the colorsting always gives #DDDD. Green, Red and Space values int he How to fix this?
string colorstring;
int Blue = 13;
int Green = 0;
int Red = 0;
int Space = 14;
colorstring = String.Format("#{0:X}{0:X}{0:X}{0:X}", Blue, Green, Red, Space);
The number
0in{0:X}refers to the position in the list or arguments. In this case0means use the first value, which isBlue. Use{1:X}for the second argument (Green), and so on.The syntax for the format parameter is described in the documentation:
Note that in your case you only have the index and the format string. You have not specified (and do not need) an alignment component.