zoukankan      html  css  js  c++  java
  • C#随机颜色和随机字母

    //随机获取颜色

    public System.Drawing.Color GetRandomColor()
        {
            Random RandomNum_First = new Random(Guid.NewGuid().GetHashCode());
            Random RandomNum_Sencond = new Random(Guid.NewGuid().GetHashCode());
            
            //为了在白色背景上显示,尽量生成深色
            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 System.Drawing.Color.FromArgb(int_Red, int_Green, int_Blue);
        }

    //随机字母

    public static string GetPageName()
        {
            string strRand = String.Empty;
            System.Random random = new Random(Guid.NewGuid().GetHashCode());
            string str = "qwertyuiopasdfghjklmnbvcxz";
            for (int i = 0; i < 6; i++)
            {
                strRand += str[random.Next(0, 25)].ToString();
            }
            return strRand;
        }
  • 相关阅读:
    Direct2D Simple
    波动+灰度图+噪点的简单实现
    控制台和窗口应用程序转换
    read from plist file
    1366X768成为全球最流行屏幕分辨率
    游戏框架类
    Animation in Cocos2diphone
    透射
    11.20
    11.19
  • 原文地址:https://www.cnblogs.com/webapi/p/5726284.html
Copyright © 2011-2022 走看看