Advertisement
skipter

Lists Upper/Lower/Mixed Strings - Split by Word Casing

Jul 10th, 2017
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.36 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace _4.Split_by_Word_Casing
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             List <string> lowerCase = new List<string>();
  13.             List <string> upperCase = new List<string>();
  14.             List <string> mixedCase = new List<string>();
  15.             List<string> totalWords = Console.ReadLine().Split(new char[] { ' ', '!', '(', ')', ',', '.', '\'',
  16.                 '\"', ':', ';', '[', ']', '\\', '/' }, StringSplitOptions.RemoveEmptyEntries).ToList();
  17.  
  18.             string currentWord = string.Empty;
  19.  
  20.             for (int i = 0; i < totalWords.Count; i++)
  21.             {
  22.                 if (totalWords[i].All(char.IsLower))
  23.                 {
  24.                     lowerCase.Add(totalWords[i]);
  25.                 } else if (totalWords[i].All(char.IsUpper))
  26.                 {
  27.                     upperCase.Add(totalWords[i]);
  28.                 } else
  29.                 {
  30.                     mixedCase.Add(totalWords[i]);
  31.                 }
  32.             }
  33.             Console.WriteLine($"Lower-case: {string.Join(", ", lowerCase )}");
  34.             Console.WriteLine($"Mixed-case: {string.Join(", ", mixedCase)}");
  35.             Console.WriteLine($"Upper-case: {string.Join(", ", upperCase)}");
  36.          }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement