C#中的转义字符串 [英] Escaped string in C#

查看:409
本文介绍了C#中的转义字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




有人能指点我在课堂上转换一个字符串,以便它显示

转义字符为\ r,\ n请


它在2005调试器中完成,所以我希望它可以作为一个类吗?


谢谢


格雷厄姆

Hi,

Can anyone point me at the class to convert a string so that it displays
escaped chars as \r, \n etc. please

Its done in the 2005 debugger so I hope its available as a class ??.

Thanks

Graham

推荐答案

格雷厄姆,


在前面放一个@字符串,例如:


string myString = @" \r\\\
" ;;


Steve


来我的论坛寻求帮助: http:// www.wizardsolutionsusa.com

Come to my forum to get help: http://www.wizardsolutionsusa.com


史蒂夫,


感谢您的快速回复: - )。


然而这是错误的方式 - 我已经将我的字符串嵌入

控制字符 - 并且只是想显示这个 - 用控制字符

''显示为逃脱(例如\\\\ n等)。


谢谢


G.


" steve813" < ST ****** @ gmail.com>在消息中写道

news:11 ********************** @ g49g2000cwa.googlegr oups.com ...
Steve,

Thanks for the vary quick reply :-).

This is the wrong way round however - I already have my string with embedded
control characters - and simply want to display this - with control chars
''shown as escaped (eg \r\n etc.).

Thanks

G.

"steve813" <st******@gmail.com> wrote in message
news:11**********************@g49g2000cwa.googlegr oups.com...
格雷厄姆,

在字符串前放一个@,例如:

string myString = @" \r\\\
" ;;

Steve
Graham,

Put an @ in front of the string, example:

string myString = @"\r\n";

Steve



这篇关于C#中的转义字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆