Domanda

Diciamo che ho la stringa:

"MyNamespace.SubNameSpace.MyClassName"

Come faccio a estrarre proprio tutto dopo l'ultimo periodo, "MyClassName"

È stato utile?

Soluzione

Usa String.Substring e String.LastIndexOf metodi.

string str = "MyNamespace.SubNameSpace.MyClassName";
string str1 = str.Substring(str.LastIndexOf('.') + 1);
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top