theThe way iI always do this is like this:
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 example_string_to_int { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { string a = textBox1.Text; // thisThis turns the text in text box 1 into a string int b; if (!int.TryParse(a, out b)) { MessageBox.Show("this"This is not a number"); } else { textBox2.Text = a+" is a number" ; } // thenThen this if'if' statmentstatement says if the string is not a number, display an error, elceelse now you will have an intagerinteger. } } } thisThis is how iI would do it, i hope this helps. (: