C# - 四則演算
二つの項目での演算を行う。

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace pjCalc
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
cmbList.SelectedIndex = 0;
}
private void btnCalc_Click(object sender, EventArgs e)
{
int value1;
int value2;
try
{
value1 = int.Parse(txtInput1.Text);
value2 = int.Parse(txtInput2.Text);
switch (cmbList.SelectedIndex)
{
case 0:
txtAnswer.Text = (value1 + value2).ToString();
break;
case 1:
txtAnswer.Text = (value1 - value2).ToString();
break;
case 2:
txtAnswer.Text = (value1 * value2).ToString();
break;
case 3:
if (value1 % value2 == 0)
{
txtAnswer.Text = (value1 /
value2).ToString();
}
else
{
txtAnswer.Text = (value1 /
value2).ToString() + "..." + (value1 % value2).ToString();
}
break;
default:
;
break;
}
}
catch (Exception ex)
{
MessageBox.Show("数値を入力してください。");
}
}
}
}