How do I get everything after a certain index in string c#

前端 未结 1 1464
野趣味
野趣味 2021-01-11 11:00

Lets say I have the string:

\"MyNamespace.SubNameSpace.MyClassName\"

How do I extract just everything after the last period, \"MyClassName\"

相关标签:
1条回答
  • 2021-01-11 11:20

    Use String.Substring and String.LastIndexOf methods.

    string str = "MyNamespace.SubNameSpace.MyClassName";
    string str1 = str.Substring(str.LastIndexOf('.') + 1);
    
    0 讨论(0)
提交回复
热议问题