• 大小: 110KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-05-29
  • 语言: C#
  • 标签: C#  

资源简介

值得一看的小游戏,比较有意思的C#小程序,源码通俗易懂,适合初学者小白,是个压缩包,适合展示给授课老师看。

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Threading.Tasks;

namespace 猜数
{
    public partial class Form1 : Form
    {
        int n;
        public Form1()
        {
           
            InitializeComponent();
        }

        private void Form1_Load(object sender EventArgs e)
        {

        }

        private void button1_Click(object sender EventArgs e)
        {
            Random a = new Random();
            n = a.Next(1 101);
            int x = 10;
            int y = 60;
            for (int i = 0; i < 100; i++)
            {
                label1.Visible = false;
                Button bt = new Button();
                bt.BackColor = System.Drawing.Color.SteelBlue;
                bt.Text = (i + 1).ToString();
                bt.Name = (i + 1).ToString();
                bt.Width = 40;
                bt.Height = 40;
                bt.Location = new Point(x y);
                bt.Click += new EventHandler(bt_Click);
                x +=36;
                if ((i + 1) % 10 == 0)
                {
                    x = 10;
                    y += 36;
                }
                Controls.Add(bt);
            }
        }

        private void button2_Click(object sender EventArgs e)
        {
            Application.Exit();
        }

        private void bt_Click(object sender EventArgs e)
        {
            Button but = (Button)sender;
            int t = int.Parse(but.Text);
            if (t == n)
            {
                label1.Text = “ 恭喜你猜对啦 “;
                label1.Visible = true;
                    but .BackColor = System .Drawing .Color .Red;
            }
            else if(t < n )
                but.Text  = “小了“;
            else
                  but.Text  = “大了“;
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件      27136  2019-10-06 17:34  猜数\猜数\bin\Debug\猜数.exe

     文件      26112  2019-10-06 17:34  猜数\猜数\bin\Debug\猜数.pdb

     文件      11600  2019-10-06 17:34  猜数\猜数\bin\Debug\猜数.vshost.exe

     文件        490  2018-09-15 15:29  猜数\猜数\bin\Debug\猜数.vshost.exe.manifest

     文件       2026  2019-10-05 19:43  猜数\猜数\Form1.cs

     文件       4697  2019-10-05 19:17  猜数\猜数\Form1.Designer.cs

     文件      31192  2019-10-05 19:17  猜数\猜数\Form1.resx

     文件       5420  2019-10-06 17:33  猜数\猜数\obj\x86\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6296  2019-10-06 17:34  猜数\猜数\obj\x86\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件        586  2019-10-06 17:34  猜数\猜数\obj\x86\Debug\猜数.csproj.FileListAbsolute.txt

     文件        975  2019-10-05 19:17  猜数\猜数\obj\x86\Debug\猜数.csproj.GenerateResource.Cache

     文件       9174  2019-10-06 17:34  猜数\猜数\obj\x86\Debug\猜数.csprojResolveAssemblyReference.cache

     文件      27136  2019-10-06 17:34  猜数\猜数\obj\x86\Debug\猜数.exe

     文件      17209  2019-10-05 19:17  猜数\猜数\obj\x86\Debug\猜数.Form1.resources

     文件      26112  2019-10-06 17:34  猜数\猜数\obj\x86\Debug\猜数.pdb

     文件        180  2019-10-05 18:15  猜数\猜数\obj\x86\Debug\猜数.Properties.Resources.resources

     文件        487  2019-10-05 17:41  猜数\猜数\Program.cs

     文件       1344  2019-10-05 17:41  猜数\猜数\Properties\AssemblyInfo.cs

     文件       2864  2019-10-05 17:41  猜数\猜数\Properties\Resources.Designer.cs

     文件       5612  2019-10-05 17:41  猜数\猜数\Properties\Resources.resx

     文件       1093  2019-10-05 17:41  猜数\猜数\Properties\Settings.Designer.cs

     文件        249  2019-10-05 17:41  猜数\猜数\Properties\Settings.settings

     文件       3671  2019-10-05 18:15  猜数\猜数\猜数.csproj

     文件        860  2019-10-05 17:41  猜数\猜数.sln

    ..A..H.     17920  2019-10-07 20:17  猜数\猜数.suo

     目录          0  2019-10-05 17:41  猜数\猜数\obj\x86\Debug\TempPE

     目录          0  2019-10-06 17:34  猜数\猜数\obj\x86\Debug

     目录          0  2019-10-05 18:15  猜数\猜数\bin\Debug

     目录          0  2019-10-05 17:41  猜数\猜数\obj\x86

     目录          0  2019-10-05 17:41  猜数\猜数\bin

............此处省略7个文件信息

评论

共有 条评论