I have a string that is populated from an Xceed datagrid, as such:
study = row.Cells["STUDY_NAME"].Value.ToString().TrimEnd (Environment.NewLine.ToCharArray());
However, when I pass the study string into another part of the program, it throws an error as the string is still showing as : "PI3K1003\n "
I have also tried:
TrimEnd('\r', '\n');
Anybody any ideas?
Thanks.
TrimEnd('\r', '\n');
isn't working because you have a space at the end of that string, use
TrimEnd('\r', '\n', ' ');
The problem in that string is that you do not have a \n
at the end. You have a ' '
(blank) at the end, and therefore \n
does not get trimmed.
So I would try TrimEnd( ' ', '\n', '\r' );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With