static void Main(string[] args) { using (System.IO.StreamWriter file = new StreamWriter("MyFile.txt")) { try { string sstr = "h"; SomeString MyStr = new SomeString("Hello students and Unstudents"); MyStr.Equals("elloH"); SomeString SecondStr = new SomeString("d sd"); file.WriteLine(MyStr.Compare(MyStr, MyStr)); file.WriteLine(MyStr.Del()); file.WriteLine(SecondStr + sstr); file.WriteLine(-SecondStr); List <SomeString> list = new List <SomeString>(); list.Add(MyStr); list.Add(SecondStr); SomeString[] arr = new SomeString[] { MyStr, SecondStr }; var coll = arr.Where(x => x.MyString.Contains(' ')).Count(); Console.WriteLine(coll); } catch (MyException x) { Console.WriteLine(x.Message); } } }
public static int CountOfSpaces(this SomeString a) { int count = 0; for (int i = 0; i < a.MyString.Length; i++) { if (a.MyString[i] == ' ') { count++; } } return(count); }
public static string Del(this SomeString a) { string[] arr; arr = a.MyString.Split(',', '.', ';', ':', '-'); return(String.Join("", arr)); }