I have a String which contains a substrings One of them is \"1 . 2 To Other Mobiles\" and other is \"Total\".Now as per my requirement i have to read the Contents between first
Problem : you are not adding the length of the first search string 1 . 2 To Other MobilessubstringTotal
Solution :
string currentText = "1 . 2 To Other MobilessubstringTotal";
string search1="1 . 2 To Other Mobiles";
string search2="Total";
int startPosition = currentText.IndexOf(search1);
int endPosition = currentText.IndexOf(search2);
string result = currentText.Substring((startPosition+search1.Length), endPosition - (startPosition+search1.Length));
Output:
result => substring