Exemplo n.º 1
0
 private void textBox1_TextChanged(object sender, EventArgs e)
 {
     if (textBox1.Text != "")
     {
         int n = 0;
         if ((int.TryParse(textBox1.Text, out n)) && (n >= 0))
         {
             Class1 obj = new Class1();
             int    F   = obj.Factorial(n);
             string a   = F.ToString();
             label1.Text = a;
         }
         else
         {
             label1.Text = "Некорректный ввод";
         }
     }
 }
Exemplo n.º 2
0
        public void button2_Click(object sender, EventArgs e)
        {
            int n;


            if (!Int32.TryParse(textBox2.Text, out n))
            {
                MessageBox.Show("!!!");
            }

            else
            {
                n = Class1.Factorial(n);
                if (n == 0)
                {
                    MessageBox.Show("!!!");
                }
                else
                {
                    label3.Text = Convert.ToString(n);
                }
            }
        }