(1)加減乗除の計算 using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Sample2 { class CSHAPRO0301 { static void Main(string[] args) { Console.Write("x = "); double x = double.Parse(Console.ReadLine()); Console.Write("y = "); double y = double.Parse(Console.ReadLine()); Console.Write("x + y = {0}\n", x + y); Console.Write("x - y = {0}\n", x - y); Console.Write("x * y = {0}\n", x * y); Console.Write("x / y = {0}\n", x / y); Console.Write("x % y = {0}\n", x % y); Console.ReadKey(); } } } (2)クリックで円を描画 using System; using System.Windows.Forms; using System.Drawing; using System.Collections.Generic; class Sample : Form { private List ls; public static void Main() { Application.Run(new Sample()); } public Sample() { this.Text = "サンプル"; this.Width = 600; this.Height = 600; ls = new List(); this.MouseDown += new MouseEventHandler(fm_Click); this.Paint += new PaintEventHandler(fm_Paint); } public void fm_Click(object sender, MouseEventArgs e) { Point p = new Point(); p.X = e.X; p.Y = e.Y; ls.Add(p); this.Invalidate(); } public void fm_Paint(object sender, PaintEventArgs e) { Graphics g = e.Graphics; Pen dp = new Pen(Color.Black, 1); foreach ( Point p in ls ) { int x = p.X; int y = p.Y; g.DrawEllipse(dp, x, y, 10, 10); } } }