Advertisement
Gillito

Untitled

Jun 5th, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.38 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.  
  7. namespace ConsoleApplication33
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             StringTool objString = new StringTool();
  14.  
  15.             Console.WriteLine(objString.LettersClean(Console.ReadLine()));
  16.             Console.WriteLine(objString.DigitsClean(Console.ReadLine()));
  17.             Console.WriteLine(objString.CleansHistory());
  18.         }
  19.     }
  20.  
  21.     class StringTool
  22.     {
  23.         private List<string> StringList = new List<string>();
  24.  
  25.         public string LettersClean(string somestring)
  26.         {
  27.             StringList.Add(somestring);
  28.             string resultString = null;
  29.             foreach (char a in somestring)
  30.                 if (!char.IsLetter(a))
  31.                     resultString += a;
  32.             return resultString;
  33.         }
  34.  
  35.         public string DigitsClean(string somestring)
  36.         {
  37.             StringList.Add(somestring);
  38.             string resultString = null;
  39.             foreach (char a in somestring)
  40.                 if (!char.IsDigit(a))
  41.                     resultString += a;
  42.             return resultString;
  43.         }
  44.  
  45.         public string CleansHistory()
  46.         {
  47.             string previous = StringList[StringList.Count - 1];
  48.             return previous;
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement