Guest User

Untitled

a guest
Jun 25th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.23 KB | None | 0 0
  1. string s = Convert.ToString(textBox1.Text);
  2. int sum = 0;
  3. for (int i = 0; i < s.Length; i++)
  4. {
  5. if (Char.IsDigit(s[i]))
  6. {
  7. string s2 = Convert.ToString(s[i]);
  8. sum += int.Parse(s2);
  9. }
  10. }
  11.  
  12. textBox2.Text = sum.ToString();
Add Comment
Please, Sign In to add comment