我需要将一个字符串文字写入文本文件,但是当我在其中使用引号字符时,C#编译器会发现错误.
我目前的代码:
writeText.WriteLine("<?xml version="1.0" encoding="utf-8"?>");
Run Code Online (Sandbox Code Playgroud)
我需要文本文件的输出为:
<?xml version="1.0" encoding="utf-8"?>
Run Code Online (Sandbox Code Playgroud)
如何在C#中将引号字符放在字符串中?
我已经编写了一些代码来随着故事的进展更新玩家。当玩家点击一个按钮时,他们会看到一些新文本和更多选项。到目前为止一切顺利,但是当我传递一个带有参数的函数调用时,我需要单引号和双引号。但是,如果我同时使用两者,则会破坏innerHTML。代码如下(如果需要也可以发布HTML):
function buttonClicked(buttonid) {
switch(buttonid) {
case "YesStart":
document.getElementById("storybox").innerHTML = "Initially she fails to notice you and stares into the distance with dazed look of someone who has considered the exact point at which the universe might have ended, present within a kind of altered dimensionality that places her materially at a similar point of existence to you, while leaving her utterly absent from it in some other, more absolute sense. Two nuns scurry past her, heading towards a small, …
Run Code Online (Sandbox Code Playgroud) 当我收到一串空白("")并尝试按下按钮时将其设置在剪贴板上,程序崩溃.
我们说吧
this.button1.onclick+=new Eventhandler(clicked);
Run Code Online (Sandbox Code Playgroud)
方法
void onclick(object sender,EventArge e)
{
clipboard.Settext(textbox1.Text); // textbox1.text is blank
}
Run Code Online (Sandbox Code Playgroud)
当我点击按钮时,它崩溃了.
有人可以帮我弄这个吗?