I want to simply remove the last character of a string that is of an undefined length. This is what I have:
var str = txtBx1.Text;
txtBx2.Text = (str.TrimEnd(str[str.Length - 1]));
It works great, when the last two characters are unique. However, when the last two or more characters are the same, all of the repeating characters are removed.
If txtBx1.Text = '123456789'
then txtBx2.Text
will be '12345678'
If txtBx1.Text = '199999999'
then txtBx2.Text
will be '1'; it needs to be '19999999'
How can I simply remove the last character of a string that is of an undefined length?