Advertisement
Guest User

Untitled

a guest
Nov 16th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4.  
  5. namespace ConsoleApp2
  6. {
  7. class Program
  8. {
  9. static void Main(string[] args)
  10. {
  11. string[] userNames = Console.ReadLine().Split(", ");
  12.  
  13. List<string> validUserNames = new List<string>();
  14.  
  15. for (int i = 0; i < userNames.Length; i++)
  16. {
  17. string user = userNames[i];
  18. int count = 0;
  19. if (user.Length >= 3 && user.Length <= 16)
  20. {
  21. foreach (var symbol in user)
  22. {
  23. if (char.IsLetterOrDigit(symbol) || symbol == '-' || symbol == '_')
  24. {
  25. count++;
  26. }
  27.  
  28. }
  29. if (count == user.Length)
  30. {
  31. validUserNames.Add(user);
  32. }
  33. }
  34. }
  35.  
  36. Console.WriteLine(string.Join(Environment.NewLine, validUserNames));
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement