Advertisement
Guest User

Untitled

a guest
Jun 27th, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. string s = textBox1.Text;
  2.  
  3. bool check = true;
  4.  
  5.  
  6. for (int i = 0; i < s.Length; i++)
  7. {
  8. if (!((s[i] >= 'А' && s[i] <= 'Я') || s[i] == ' ' || s[i] == ',' || (s[i] >= 'а' && s[i] <= 'я')))
  9. check = false;
  10. }
  11.  
  12. string[] names =s.Split (new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
  13. if (!(names.Length == 3))
  14. check = false;
  15. for (int i = 0; i < 3; i++)
  16. {
  17.  
  18.  
  19. string str = names[0].ToString();
  20. str += names[1].ToString().Substring(0, 1);
  21. //str += names[2].ToString().Substring(0, 1);
  22. listBox1.Items.Add(str);
  23.  
  24. }
  25.  
  26.  
  27. if (!check)
  28. {
  29. MessageBox.Show("Накосячили");
  30. textBox1.Clear();
  31. }
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement