How to get the second last string in C#

后端 未结 4 1683
梦谈多话
梦谈多话 2021-01-22 01:45

Example1:

string input = \"Village Siaban  WDT no.39 91308 Semporna Sabah\";

Example2:

string input = \"Village Hw WDT no.39          


        
4条回答
  •  不要未来只要你来
    2021-01-22 02:15

    string input = "Village Siaban  WDT no.39 91308 Semporna Sabah";
    
    string secondToLastWord = input.Split(' ').Reverse().ElementAt(1).ToString();
    

提交回复
热议问题