开发者

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


This should work:

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

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜