.net - Selecting a specific part of a string C# -


i trying create new string, removes characters existing string e.g.

string path = "c:\test.txt" 

so string "pathminus" take out "c:\" e.g.

string pathminus = "test.txt" 

the string class offers sorts of ways this.

if want change "c:\test.txt" "test.txt" removing first 3 characters:

path.substring(3); 

if want remove "c:\" anywhere in string:

path.replace("c:\", ""); 

or if want filename, regardless of how long path is:

path.getfilename(path); 

depending on intentions, there many ways it. prefer using static class path.


Comments

Popular posts from this blog

javascript - Iterate over array and calculate average values of array-parts -

iphone - Using nested NSDictionary with Picker -

objective c - Newbie question -multiple parameters -