C#:关于双引号的输出
法一:使用轉義字符
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication5
{
??? class Program
??? {
??????? static void Main(string[] args)
??????? {
??????????? Console.WriteLine("\"ning\"");
??????????? Console.ReadKey();
??????? }
??? }
}
?
?
法二:使用@.其他字符按代碼的格式輸出即可,雙引號輸出比較特殊,用兩個雙引號代表。
?
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication5
{
??? class Program
??? {
??????? static void Main(string[] args)
??????? {
??????????? Console.WriteLine (@"""n""ing peiyang");
??????????? Console.ReadKey();
??????? }
??? }
}
?
如果是這樣無法通過編譯——
錯誤代碼一
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication5
{
??? class Program
??? {
??????? static void Main(string[] args)
??????? {
??????????? Console.WriteLine(@"\"ning\"");
??????????? Console.ReadKey();
??????? }
??? }
}
?
錯誤代碼二:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication5
{
??? class Program
??? {
??????? static void Main(string[] args)
??????? {
??????????? Console.WriteLine(@""ning"");
??????????? Console.ReadKey();
??????? }
??? }
}
轉載于:https://www.cnblogs.com/freedom831215/archive/2010/08/02/1790275.html
超強干貨來襲 云風專訪:近40年碼齡,通宵達旦的技術人生總結
以上是生活随笔為你收集整理的C#:关于双引号的输出的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: Base64 加密字符串和文件
- 下一篇: C#基础-可空类型