A simple code snippet is as follows:
public static void Main()
{
string str = "IsRecorded<code>0</code>";
str = str.TrimEnd("<code>0</code>".ToCharArray());
Console.WriteLine(str);
}
The output string that I get is IsRecor
. Why does the TrimEnd
function strips of ded
from the string when it is supposed to strip only <code>0</code>
. Also if I reduce the str
to IsRec
then it gives IsR
as output. Why is this happening?
0
", Regex.Escape("0
") + "$", "")`. (There are more efficient alternatives, but something something premature optimization.) – Jeroen Mostert Apr 23 '19 at 12:48