Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Linq;
- namespace P01.Valid_Username
- {
- class Program
- {
- static void Main()
- {
- string[] input = Console.ReadLine().Split(", ",StringSplitOptions.None).ToArray();
- foreach (var username in input)
- {
- if (ValidUsername(username))
- {
- Console.WriteLine(username);
- }
- }
- }
- static bool ValidUsername(string username)
- {
- bool isValid = true;
- if (username.Length<3||username.Length>16)
- {
- return false;
- }
- for (int i = 0; i < username.Length; i++)
- {
- char currCh = username[i];
- if (char.IsLetterOrDigit(currCh)||currCh=='-'|| currCh=='_')
- {
- isValid = false;
- break;
- }
- }
- return isValid;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement