when enter the text to find the string i want to ignore the case how to implement that in a context below Code: public override void Search() { //file = new FileStream(@"C:\username.txt", FileMode.Open, FileAccess.Read); Console.WriteLine("Input a string "); String data = Console.ReadLine(); sr = File.OpenText(@"C:\username.txt"); String st = sr.ReadToEnd(); // How to implement ignore cases if (st.Contains(data)) { Console.WriteLine("Found at position :" + st.IndexOf(data)); } else { Console.WriteLine("Not Found"); } Thanks,
I made an error CompareNoCase is for CString of C++ and not for C# but its CompareTo and I guess the best option is to make each of them to the same case.
Thanks Shabbir for this but i got one solution on my own but now as Search functionality works i have something same in switch cases Code: String s; s = Console.ReadLine(); switch (s) { case "g": Console.Clear(); uname.getUserName(); return choices(); // break; if i want to enter "G" it doesnt accept how to do that?
2 Options. Have a case Fall Through with "G" and g like the one below. Code: String s; s = Console.ReadLine(); switch (s) { case "g": case "G": Console.Clear(); uname.getUserName(); return choices(); // break; or convert the s to the lower case with ToLower.
Thanks a million, Shabbir. It worked for me. Now i will continue on how to delete a line from the text file. I will do separate thread at some stage.