tags:

views:

135

answers:

1

Lets say I have the string:

"MyNamespace.SubNameSpace.MyClassName"

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

+8  A: 

Use String.Substring and String.LastIndexOf methods.

string str = "MyNamespace.SubNameSpace.MyClassName";
string str1 = str.Substring(str.LastIndexOf('.') + 1);
rahul
+1 for adding the +1 to get everything *after* the last period.
Jon Skeet
Thanks @Jon for the edit.
rahul