Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ManipulateString
- {
- public bool result { get; private set; }
- private char[] StringToChar(string Word)
- {
- char[] myChar = Word.ToCharArray();
- //zwraca łancuch znaków w postaci tablicy znaków
- return myChar;
- }
- private int[] CharToAscii(char[] Letter)
- {
- int i = 0;
- int[] temp = new int[Letter.Length];
- while (i < Letter.Length)
- {
- temp[i] = (int)Letter[i];
- i++;
- }
- //zwraca tablice intow z zawartoscia kodu asci
- return temp;
- }
- private bool[] CheckWordRangeOfAscii(int rangeForm, int rangeTo, int[] valueOfArray)
- {
- bool[] temp = new bool[valueOfArray.Length];
- for (int i = 0; i < valueOfArray.Length; i++)
- {
- if (valueOfArray[i] >= rangeForm && valueOfArray[i] <= rangeTo)
- {
- temp[i] = true;
- }
- else if (valueOfArray[i] < rangeForm && valueOfArray[i] > rangeTo)
- {
- temp[i] = false;
- }
- }
- return temp;
- }
- public bool CheckTrueCheckFalse(bool[] value)
- {
- bool temp = true;
- for (int i = 0; i < value.Length; i++)
- if ((value[i] == false))
- {
- temp = false;
- }
- return temp;
- }
- /// <summary>
- /// Sprawdza czy podany wyraz znajduje się w podanym przedziale kodu ASCII
- /// </summary>
- /// <param name="rangeFrom">podaj niższą wartość wymaganego ascii</param>
- /// <param name="rangeTo">podaj wyższą wartość wymaganego ascii</param>
- /// <param name="word">podaj słowo które chcesz sprawdzić czy miesci się w przedziale</param>
- public ManipulateString(int rangeFrom, int rangeTo, string word)
- {
- this.result = CheckTrueCheckFalse(CheckWordRangeOfAscii(rangeFrom, rangeTo, (CharToAscii(StringToChar(word)))));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement