zoukankan      html  css  js  c++  java
  • 随机数的使用

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;
    using System.Threading;
    
    namespace 摇奖机
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
    
            private void Form1_Load(object sender, EventArgs e)
            {
                this.Text = "抽奖机";
                button1.Text = "开始";
                Control.CheckForIllegalCrossThreadCalls = false;
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                if(b == false)
                {
                    b = true;
                    button1.Text = "停止";
                    Thread th = new Thread(PlayGame);
                    th.IsBackground = true;
                    th.Start();
                    //PlayGame();
                }
                else
                {
                    b = false;
                    button1.Text = "开始";
                }
    
            }
    
            bool b = false;
            private void PlayGame()
            {
                //随机数的使用
                Random r = new Random();
                while(b)
                {
                    //在[0-9]整数
                    label1.Text = r.Next(0, 10).ToString();
                    label2.Text = r.Next(0, 10).ToString();
                    label3.Text = r.Next(0, 10).ToString();
                    Thread.Sleep(100);
                }
            }
        }
    }
    

      

  • 相关阅读:
    C#时间差
    centos8安装ffmpeg
    CentOS8同步时间
    安装Supervisor
    ajax 传递 token
    .net core 3.1 中 的跨域设置
    jaeger 本地编译
    Kubernates 环境搭建
    linux : find
    Linux: 文件分割和合并
  • 原文地址:https://www.cnblogs.com/my-cat/p/7428858.html
Copyright © 2011-2022 走看看