Advertisement
Guest User

Untitled

a guest
Nov 14th, 2018
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.90 KB | None | 0 0
  1. public partial class Form1 : Form
  2. {
  3. public Form1()
  4. {
  5. InitializeComponent();
  6. }
  7.  
  8. private void button1_Click(object sender, EventArgs e)
  9. {
  10. textBox2.Text = textBox1.Text;
  11. }
  12.  
  13. private void textBox1_TextChanged(object sender, EventArgs e)
  14. {
  15. int spaces = 0, commas = 0;
  16. foreach (char ch in textBox1.Text)
  17. {
  18. if (ch == 32) spaces++;
  19. if (ch == 44) commas++;
  20. }
  21. if (spaces - commas == 3 && commas != 2)
  22. {
  23. string[] strMass = textBox1.Text.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
  24. string str = string.Join(" ", strMass) + ", ";
  25. textBox1.Text = str;
  26. textBox1.Select(textBox1.Text.Length, 0);
  27. }
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement