sleep, or lack thereof.
Posted by detour1999 | Filed under general, nerdly
Couldn’t sleep last night… shocking, I know.
Rah tried to help with the following
“Try to think of 100 colors.”
it helped for about 3 seconds while I wrote this in my head:
public string[] ListColors(int numColors)
{
ArrayList colorList = new ArrayList();
for (int curColor = 0; curColor < numColors; curColor++)
{
string newColor = Convert.ToString(curColor, 16);
newColor = FormatHexColor(newColor);
colorList.Add(newColor);
}
return (string[])colorList.ToArray(typeof(string));
}
private string FormatHexColor(string newColor)
{
string retStr = "#";
int leadLength = 6-newColor.Length;
for (int a = 0; a < leadLength; a++)
{
retStr += "0";
}
retStr += newColor;
return retStr;
}
yeah, I’m kinda lame..
private void ThisMakesMeSleepy()
{
string[] colors = ListColors(100);
foreach (string color in colors)
{
System.Diagnostics.Debug.Print(color);
}
}