Advertisement
DrAungWinHtut

Random Number CS

Feb 15th, 2022
501
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.86 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace WindowsFormsApp1
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.         }
  19.  
  20.         private void btnDice_Click(object sender, EventArgs e)
  21.         {
  22.             Random rnd = new Random(); //Random obj ဖန်တီးတာ
  23.             int iDice = rnd.Next(1, 4); //၁ နဲ့ ၂ ကြား random integer တစ်လုံး ဖန်တီးတာ
  24.             txtDice.Text = iDice.ToString(); //ရလာတဲ့ random int ကို string ပြောင်းပြီး txtDice ရဲ့ Text properties ထဲ ထည့်တာ
  25.         }
  26.     }
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement