Hi,
How to find a substring inside the string in c# and return true if found?
ex.
Manila, Philipines = Phils343 = true
Manila, Philipines = Manila = true
Manila, Philippines = phili= true
Manila, Philippines = Cebu= false
thanks,
Popskie
Printable View
Hi,
How to find a substring inside the string in c# and return true if found?
ex.
Manila, Philipines = Phils343 = true
Manila, Philipines = Manila = true
Manila, Philippines = phili= true
Manila, Philippines = Cebu= false
thanks,
Popskie
Use string.IndexOf method. Something similar to thisVB Code:
someName = "Manila, Philipines"; if (someName.IndexOf("Phili") >= 0) MessageBox.Show ("True"); else MessageBox.Show ("False");
If it's C# 2.0 (please specify in future) and you don't actually want the index then use String.Contains.
Lol thanks for helping me. LOL
Contains() is just a bool wrapper for IndexOf(). Use IndexOf when its a speed intensive bit of code. ;)Quote:
Originally Posted by jmcilhinney