如何显示标记的“在c#的消息中? [英] How do I show marked " in the message by c#?

查看:74
本文介绍了如何显示标记的“在c#的消息中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何通过c#在消息中显示标记为

How do I show marked " in the message by c#?

推荐答案

如果您的意思是如何在字符串中插入双引号字符?有两种方法:

1)使用反斜杠字符逃脱它:

If you mean "How do I insert a double quote character in a string?" then there are two ways:
1) Escape it, using the backslash character:
string s = "Hello \"Mike Smith\" and welcome";
Console.WriteLine(s);

将打印

Will print

Hello "Mike Smith" and welcome



或者,在字符串前加上atsign,并禁用转义字符。然后,您需要使用两次双引号:


Or, prefix the string with an atsign, and it disables the escape character. Then, you need to use the double quote twice:

string s = @"Hello ""Mike Smith"" and welcome";
Console.WriteLine(s);

还将打印

Will also print

Hello "Mike Smith" and welcome





如果那不是你想要做的,那么你需要更清楚地解释一下!



If that isn't what you are trying to do, then you need to explain in much clearer detail!


这篇关于如何显示标记的“在c#的消息中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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