Advertisement
Morogn93

ManipulateString

Feb 5th, 2018
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.42 KB | None | 0 0
  1.     public class StringManipulate
  2.     {
  3.  
  4.         public char[] StringToChar(string Word)
  5.         {
  6.             char[] myChar = Word.ToCharArray();
  7.  
  8.             //zwraca łancuch znaków w postaci tablicy znaków
  9.             return myChar;
  10.         }
  11.         public int[] CharToAscii(char[] Letter)
  12.         {
  13.             int i = 0;
  14.             int[] temp = new int[Letter.Length];
  15.             while (i < Letter.Length)
  16.             {
  17.                 temp[i] = (int)Letter[i];
  18.                 i++;
  19.             }
  20.  
  21.             //zwraca tablice intow z zawartoscia kodu asci
  22.             return temp;
  23.         }
  24.         public bool CheckWordRangeOfAscii(int rangeForm, int rangeTo, int[] valueOfArray)
  25.         {
  26.             bool temp=true;
  27.  
  28.             foreach(int item in valueOfArray)
  29.             {
  30.                 if (item >= rangeForm || item <= rangeTo)
  31.                     temp = true;
  32.                 else temp = false;
  33.             }
  34.             return temp;
  35.         }
  36.         public bool CheckTrueCheckFalse(bool value)
  37.         {
  38.             if (value == true)
  39.                 return true;
  40.             return false;
  41.         }
  42.  
  43.  
  44.         public bool CheckWord(string Word, int rangeForm, int rangeTo)
  45.         {
  46.             char[] arrayChar = StringToChar(Word);
  47.             return CheckTrueCheckFalse(CheckWordRangeOfAscii(rangeForm, rangeTo, (CharToAscii(StringToChar(Word)))));
  48.  
  49.         }
  50.        
  51.  
  52.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement