日期:2014-05-17  浏览次数:20816 次

代码显示问题
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace fac
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        public class jiecheng
        {
            public int num;
            public int fac(int n)
            {
                if (n < 2)
                    return (n);
                else 
                    return (n * fac(n - 1));
            }
        }
        
        private void label1_Click(object sender, EventArgs e)
        {
           jiecheng number=new jiecheng();
           number.num = Convert.ToInt16(textBox1.Text);
           textBox2.Text = number.fac(number.num).ToString();
        }

        
    }
}

这是一个就n阶乘的递归运算,但是为什么不能在textBox2.Text中显示出来呢?

------解决方案--------------------
你在哪里调用 label1_Click 方法了,如果调用了,就断点跟进去,一看便知
------解决方案--------------------
引用:
引用:你在哪里调用 label1_Click 方法了,如果调用了,就断点跟进去,一看便知
C# code?12345678910111213141516171819202122232425262728293031323334353637383940using System;using System.Collections.Generic;usi……

你的button1.Click事件是这样绑定的吗?
button1.Click+=button1_Click