这样的数字转字符串有什么作用呢?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace Ex04_07
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }        private void button1_Click(object sender, EventArgs e)
        {
            textBox2.Text = Convert.ToString(Convert.ToInt32(textBox1.Text));
        }
    }
}

解决方案 »

  1.   

    To check whether the text in textBox1 is of the number format
      

  2.   

    Sorry, i cannot type Chinese right now. Am installing chinese language pack.
      

  3.   

    It is better to add Exception handling codetry{
    textBox2.Text = Convert.ToString(Convert.ToInt32(textBox1.Text));
    }catch
    {
    MessageBox.Show("The input is of wrong format, please input a number!");
    }
      

  4.   

    只有textBox1是数字的情况才复制到textBox2,但这样写并不好,如果textBox1不是数字会引发异常.
    下面得写法比较好
    private void button1_Click(object sender, EventArgs e)
    {
      int num;
      if(int.TryParse(textBox1.Text,out num))
      {
         textBox2.Text = textBox1.Text;
      }
    }
      

  5.   

    这样写textBox1只能输入数字,如果是其它字符就转不成int32了,就会出错,如果用try...catch处理一下,就可以验证是否输入的是数字。