I need to trim a substring from a string if that substring exists.
In particular, if the line is "MainGUI.exe", then I need it to become "MainGUI", by trimming ".exe" from the line.
I tried this:
String line = "MainGUI.exe";
char[] exe = {'e', 'x', 'e', '.'};
line.TrimEnd(exe);
This gives me the correct answer for "MainGui.exe", but for something like "MainGUIe.exe" it does not work, giving me "MainGUI" instead of "MainGUIe".
I am using C #. Thanks for the help!
source
share