get all characters to right of last dash

前端 未结 9 389
遇见更好的自我
遇见更好的自我 2020-12-07 13:50

I have the following:

string test = \"9586-202-10072\"

How would I get all characters to the right of the final - so 10072. Th

相关标签:
9条回答
  • 2020-12-07 14:25

    test.Substring(test.LastIndexOf("-"))

    0 讨论(0)
  • 2020-12-07 14:26

    See String.lastIndexOf method

    0 讨论(0)
  • 2020-12-07 14:28
    string tail = test.Substring(test.LastIndexOf('-') + 1);
    
    0 讨论(0)
提交回复
热议问题