概要
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 i;
int j;
int s;
string res = "";
for (i = 1; i < 10; i++)
{
for (j = 1; j < 10; j++)
{
s = i * j;
if (s < 10) res += " ";
res += s.ToString() + " ";
}
res += "\r\n";
}
bo1.Text = res;
}
[STAThread]
public static void Main() {
Application.Run(new form1());
}
}
以上。