Saturday, January 3, 2009

Color char in any string

string name = "hello vinod how r u";

Random rd=new Random();

CharEnumerator ct = name.GetEnumerator();
while (ct.MoveNext())
{

int r = rd.Next(0, 255);
int g = rd.Next(0, 255);
int b = rd.Next(0, 255);
string rgb = r.ToString() + "," + g.ToString() + "," + b.ToString();
Response.Write("<span style='color:rgb(" + rgb + ");font-weight:bold;font-family:Verdana;font-size:15px'>" + ct.Current + "</span><br />");
}
Share:

0 Comments:

Post a Comment