این 3تا رو به فرم اضافه کن ( با اسم های پیش فرض) Lable, TextBox, Button
بعدش این کد رو بنویس:
public partial class Form1 : Form
{
List<int> NUMBERS;
public Form1()
{
InitializeComponent();
NUMBERS = new List<int>();
}
private void button1_Click(object sender, EventArgs e)
{
NUMBERS.Add(int.Parse(textBox1.Text));
label1.Text = string.Format("{0} Item(s) Remaining...", 20 - NUMBERS.Count());
textBox1.Clear();
if (NUMBERS.Count() == 20)
{
label1.Text = string.Format("Average is: {0}", NUMBERS.Average());
textBox1.Enabled = button1.Enabled = false;
}
}
}