Need to get a string after a “word” in a string in c#

前端 未结 7 1591
被撕碎了的回忆
被撕碎了的回忆 2020-12-08 13:45

i\'m having a string in c# for which i have to find a specific word \"code\" in the string and have to get the remaining string after the word \"code\".

The string i

7条回答
  •  离开以前
    2020-12-08 14:00

    string originalSting = "This is my string";
    string texttobesearched = "my";
    string dataAfterTextTobeSearch= finalCommand.Split(new string[] { texttobesearched     }, StringSplitOptions.None).Last();
    if(dataAfterTextobeSearch!=originalSting)
    {
        //your action here if data is found
    }
    else
    {
        //action if the data being searched was not found
    }
    

提交回复
热议问题