How to Read Substrings based on Length of the String in C#

前端 未结 5 1671
有刺的猬
有刺的猬 2021-01-23 16:06

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

5条回答
  •  独厮守ぢ
    2021-01-23 17:10

    try this.

    int startPosition = currentText.IndexOf("1 . 2 To Other Mobiles");
    int endPosition = currentText.LastIndexOf("Total") + 5;
    string result = currentText.Substring(startPosition, endPosition - startPosition);
    

提交回复
热议问题