文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>解决C#用随机数产生的坐标在对角线上

解决C#用随机数产生的坐标在对角线上

时间:2010-09-02  来源:蜗小牛

 /// <summary>
        /// 初始化坐标
        /// </summary>
        /// <returns></returns>
        private Point InitPoint()
        {
            int x, y;
            long tick = DateTime.Now.Ticks;
            pointX = new Random(GetRandomSeed());
            pointY = new Random(GetRandomSeed());
            x = pointX.Next(0,this.panel1.Width-50);
            y = pointY.Next(0,this.panel1.Height-50);
            p = new Point(x, y);
            return p;
        }
        /// <summary>
        /// 随机生成种子数(摘抄)
        /// </summary>
        /// <returns></returns>
        static int GetRandomSeed()
        {
            byte[] bytes = new byte[4];
            RNGCryptoServiceProvider rng = new RNGCryptoServiceProvider();
            rng.GetBytes(bytes);
            return BitConverter.ToInt32(bytes, 0);
        }

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载