2010年10月8日 星期五

How to: Convert a string to an int (C# Programming Guide)

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 WindowsFormsApplication2
{
    public partial class Form1 : Form
    {
        Form2 newform;
        public Form1()
        {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
        }
        private void button1_Click(object sender, EventArgs e)
        {
            int a=0, b=0, c=0;
            String output;
            a = int.Parse(textBox1.Text);
            b = int.Parse(textBox2.Text);
            c = a * b;
            output = Convert.ToString(c);
            textBox3.Text = output;
        }
        private void button2_Click(object sender, EventArgs e)
        {
            newform = new Form2();
            newform.Show();
        }
    }
}

沒有留言:

張貼留言