手机
当前位置:查字典教程网 >编程开发 >asp.net教程 >asp.net 产生随机颜色实现代码
asp.net 产生随机颜色实现代码
摘要:复制代码代码如下:publicstringGetRandomColor(){RandomRandomNum_First=newRandom(...

复制代码 代码如下:

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;

}

【asp.net 产生随机颜色实现代码】相关文章:

asp.net自定义控件代码学习笔记

asp.net Xml绑定到数据控件的具体实现

asp.net高效替换大容量字符实现代码

ASP.NET Ajax级联DropDownList实现代码

asp.net用三层实现多条件检索示例

Asp.Net Cache缓存使用代码

asp.net 的错误处理机制讲解

asp.net中调用winrar实现压缩解压缩的代码

asp.net DiscuzNT登录,退出的代码

c# .net 生成图片验证码的代码

精品推荐
分类导航