Advertisement
Guest User

Untitled

a guest
Jul 19th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.27 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ValidUsername
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. string[] usernames = Console.ReadLine().Split(", ");
  10.  
  11. for (int i = 0; i < usernames.Length; i++)
  12. {
  13. bool isValidLegnth = false;
  14. bool isValidContent = false;
  15. string currentUsername = usernames[i];
  16. if (currentUsername.Length >= 3 && currentUsername.Length <= 16)
  17. {
  18. isValidLegnth = true;
  19.  
  20. }
  21. for (int j = 0; j < currentUsername.Length; j++)
  22. {
  23. char currentSymbol = currentUsername[j];
  24. if (char.IsLetterOrDigit(currentSymbol) || currentSymbol == '-' || currentSymbol == '_')
  25. {
  26. isValidContent = true;
  27.  
  28. }
  29. else
  30. {
  31. isValidContent = false;
  32. }
  33. }
  34. if (isValidContent && isValidLegnth)
  35. {
  36. Console.WriteLine(currentUsername);
  37. }
  38. }
  39.  
  40. }
  41. }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement