How to put a non static Method into a String- .Split()
I try to make a little console application in C#, where I have a given text, which cuts the part, you gave in the input (Console.ReadLine()), out. If you wonder: I am going to make a switch statement, in case the user input, cannot be found in the given text. Heres my Code: using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace ForTests { class Program { class SplitText { public static string text = "You can cut here any word you want in this text. ANY. So do it. Now."; // The uncut text in string private string input; // The methods which are carring the .ReadLine input public string Input { get { return input; } set { input = value; } } string[] words = text.Split(Input); // Here is the text.Split, where the Input method does not work public void Write() // Here is the method to assemble the text back together { for (int i = 0; i < words.Length; i++) { Console.Write(words[i]); } } public void t() //This Method shows the given text in the console { Console.WriteLine(text); } } static void Main(string[] args) { SplitText s = new SplitText(); s.Input = Console.ReadLine(); // Here I defined Input as Console.ReadLine() Console.WriteLine(": "); s.t(); // This shows the uncut text Console.WriteLine("Cutted text: "); s.Write(); // Here you get the cutted text Console.ReadKey(); } } }