asp.Netランダムカラー実装コードの生成

688 ワード

 
  
public string GetRandomColor()
{
Random RandomNum_First = new Random((int)DateTime.Now.Ticks);
// C# ,
System.Threading.Thread.Sleep(RandomNum_First.Next(50));
Random RandomNum_Sencond = new Random((int)DateTime.Now.Ticks);

// ,
int int_Red = RandomNum_First.Next(256);
int int_Green = RandomNum_Sencond.Next(256);
int int_Blue = (int_Red + int_Green > 400) ? 0 : 400 - int_Red - int_Green;
int_Blue = (int_Blue > 255) ? 255 : int_Blue;

return Color.FromArgb(int_Red, int_Green, int_Blue).Name;
}