+ 1

Strings

How can I use IndexOf to search in a string?

21st Dec 2019, 12:27 AM
Tamim Jabr
Tamim Jabr - avatar
1 Respuesta
+ 3
String s = "SoloLearn earns good vibes"; int pos = s.IndexOf("ear"); Console.WriteLine(pos); // IndexOf method returns the offset of the given // argument within a String object // Offset is a zero based positive value Console.WriteLine(s.IndexOf("ear", pos + 1)); // A second optional argument may be passed // as a starting offset where the search shall begin
21st Dec 2019, 3:18 AM
Ipang