Skip to main content
Active reading [<en.wiktionary.org/wiki/statement#Noun> <en.wiktionary.org/wiki/else#Conjunction> <en.wiktionary.org/wiki/integer#Noun>]. In English, the subjective form of the singular first-person pronoun, "I", is capitalized. Removed meta information (this belongs in comments).
Source Link
Peter Mortensen
  • 31.4k
  • 22
  • 110
  • 134

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. (:

the way i 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; // this turns the text in text box 1 into a string int b; if (!int.TryParse(a, out b)) { MessageBox.Show("this is not a number"); } else { textBox2.Text = a+" is a number" ; } // then this if statment says if the string not a number display an error elce now you will have an intager. } } } 

this is how i would do it, i hope this helps. (:

The way I 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; // This turns the text in text box 1 into a string int b; if (!int.TryParse(a, out b)) { MessageBox.Show("This is not a number"); } else { textBox2.Text = a+" is a number" ; } // Then this 'if' statement says if the string is not a number, display an error, else now you will have an integer. } } } 

This is how I would do it.

Source Link

the way i 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; // this turns the text in text box 1 into a string int b; if (!int.TryParse(a, out b)) { MessageBox.Show("this is not a number"); } else { textBox2.Text = a+" is a number" ; } // then this if statment says if the string not a number display an error elce now you will have an intager. } } } 

this is how i would do it, i hope this helps. (: