資源簡介
值得一看的小游戲,比較有意思的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?????????????????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個文件信息
- 上一篇:C#WinForm使用CefSharp內嵌
- 下一篇:C#考勤管理系統完整源碼
評論
共有 條評論