c#产生随机颜色
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string k = getStrColor();
Label1.ForeColor=System.Drawing.Color.FromName( getStrColor());
// Label1.ForeColor=Color.FromArgb(random.Next(255),random.Next(255),random.Next(255));
}
private static Random rand = new Random();
public static string getStrColor()
{
Color color = Color.FromArgb(rand.Next());
string strColor = "#" + Convert.ToString(color.ToArgb(), 16).PadLeft(8, '0').Substring(2, 6);
return strColor;
}
}