开发者

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

开发者 https://www.devze.com 2022-12-24 21:35 出处:网络
Lets say I have the string: \"MyNamespace.SubNameSpace.MyClassName\" How do I extract just everything after the last period,开发者_如何学Go \"MyClassName\"Use String.Substring and String.LastIndexOf

Lets say I have the string:

"MyNamespace.SubNameSpace.MyClassName"

How do I extract just everything after the last period,开发者_如何学Go "MyClassName"


Use String.Substring and String.LastIndexOf methods.

string str = "MyNamespace.SubNameSpace.MyClassName";
string str1 = str.Substring(str.LastIndexOf('.') + 1);
0

精彩评论

暂无评论...
验证码 换一张
取 消