How to get substring from string in c#?

前端 未结 7 1567
夕颜
夕颜 2020-12-16 12:09

I have a large string and its stored in a string variable str. And i want to get a substring from that in c#? Suppose the string is : \" Retrieves a substring from thi

7条回答
  •  情歌与酒
    2020-12-16 12:50

    You could do this manually or using IndexOf method.

    Manually:

    int index = 43;
    string piece = myString.Substring(index);
    

    Using IndexOf you can see where the fullstop is:

    int index = myString.IndexOf(".") + 1;
    string piece = myString.Substring(index);
    

提交回复
热议问题