概要
cscの作法、調べてみた。
練習問題やってみた。
練習問題
ズンドコやってみて。
写真
サンプルコード
using System;
using System.Windows.Forms;
using System.Drawing;
class form1: Form {
TextBox bo1;
form1() {
Text = "fizzbuzz";
ClientSize = new Size(300, 300);
bo1 = new TextBox();
bo1.Location = new Point(50, 80);
bo1.Width = 200;
bo1.Height = 200;
bo1.Multiline = true;
Controls.AddRange(new Control[] {
bo1
});
Button btn1 = new Button();
btn1.Location = new Point(50, 50);
btn1.Text = "test";
btn1.Click += btn1_Click;
Controls.AddRange(new Control[] {
btn1
});
}
void btn1_Click(object sender, System.EventArgs e) {
int a = 0;
int b = 0;
Random r = new Random();
string res = "";
do
{
if (a == 0)
{
b++;
}
else
{
b = 0;
}
a = r.Next(2);
if (a == 0)
{
res += "ズン ";
}
else
{
res += "ドコ ";
}
} while (!(a == 1 && b > 4));
res += "キ・ヨ・シ!!";
bo1.Text = res;
}
[STAThread]
public static void Main() {
Application.Run(new form1());
}
}
以上。