简体   繁体   中英

C# how to use the \ character in a char datatype

I would like to trim a \\ character from the end of the string. How is this done?

MyString.Value.TrimEnd('\');

simple doesn't work, and produces a newline in constant error, please help

Change this to

MyString.Value.TrimEnd('\\');

The slash has to be escaped.

\\ is an escape character, use \\\\ instead.

Bobby

这应该工作:

MyString.Value.TrimEnd((char)92);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM