Advertisement
Gillito

Untitled

Jun 5th, 2015
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.71 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.GetLastProcessedString());
  18.             objString.CleanHistory();
  19.             Console.WriteLine(objString.GetLastProcessedString());
  20.         }
  21.     }
  22.  
  23.     class StringTool
  24.     {
  25.         private List<string> StringList = new List<string>();
  26.  
  27.         public string LettersClean(string somestring)
  28.         {
  29.             StringList.Add(somestring);
  30.             string resultString = null;
  31.             foreach (char a in somestring)
  32.                 if (!char.IsLetter(a))
  33.                     resultString += a;
  34.             return resultString;
  35.         }
  36.  
  37.         public string DigitsClean(string somestring)
  38.         {
  39.             StringList.Add(somestring);
  40.             string resultString = null;
  41.             foreach (char a in somestring)
  42.                 if (!char.IsDigit(a))
  43.                     resultString += a;
  44.             return resultString;
  45.         }
  46.  
  47.         public string GetLastProcessedString()
  48.         {
  49.             string previous;
  50.             if (StringList != null)
  51.                 previous = StringList[StringList.Count - 1];
  52.             else
  53.                 previous = null;
  54.             return  previous;
  55.         }
  56.  
  57.         public void CleanHistory()
  58.         {
  59.            StringList.Clear();
  60.         }
  61.     }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement