【问题标题】:How to use ` ` in c# [duplicate]如何在c#中使用``
【发布时间】:2020-07-08 15:07:40
【问题描述】:

我想将 ASCII 艺术添加到 c# 控制台应用程序中,但这不起作用。

在javascript中,我可以做到这一点

console.log(` hey `)

但我不能在 c# 中做同样的事情

console.WriteLine(` hey `)

我该怎么办?

编辑:

我希望能够做到这一点

Console.WriteLine(`
hello :))
:]

`)

【问题讨论】:

  • C# 要求字符串用双引号 (" hey ") 而非反引号 (` hey `) 括起来。
  • 你的意思是双引号?
  • console.WriteLine(" ` hey ` ")
  • 如果你想在 C# 中做多行字符串,你必须在开头的引号前加上一个@:string str = @"multi line string goes here";

标签: c# console-application


【解决方案1】:

选择你想要的

Console.WriteLine(" hey ")
//will print:  hey

Console.WriteLine("` hey `")
//will print: ` hey `

【讨论】:

    猜你喜欢
    • 2021-10-28
    • 1970-01-01
    • 1970-01-01
    • 2021-04-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-09-14
    相关资源
    最近更新 更多