How to remove a defined part of a string?

string.TrimStart(what_to_cut); // Will remove the what_to_cut from the string as long as the string starts with it.  

"asdasdfghj".TrimStart("asd" ); will result in "fghj".
"qwertyuiop".TrimStart("qwerty"); will result in "uiop".


public static System.String CutStart(this System.String s, System.String what)
{
    if (s.StartsWith(what))
        return s.Substring(what.Length);
    else
        return s;
}

"asdasdfghj".CutStart("asd" ); will now result in "asdfghj".
"qwertyuiop".CutStart("qwerty"); will still result in "uiop".


Given that "\" always appear in the string

var s = @"NT-DOM-NV\MTA";
var r = s.Substring(s.IndexOf(@"\") + 1);
// r now contains "MTA"

you can use this codes:

str = str.Substring (10); // to remove the first 10 characters.
str = str.Remove (0, 10); // to remove the first 10 characters
str = str.Replace ("NT-DOM-NV\\", ""); // to replace the specific text with blank

//  to delete anything before \

int i = str.IndexOf('\\');
if (i >= 0) str = str.SubString(i+1);