0

hi guys I made an app to extract .lua file when I push the button my problem is I need to pass this string like this

QUESTID = LuaGetQuestID("QNO_QUEST_AR")

QNO_QUEST_AR extracted from textBox1 so my code =

            File.Write("  QUESTID = LuaGetQuestID("+textBox1.Text+")\r\n");

I need to add 2x " mark like this (""+textBox1.Text+"") anyway to do that ? thanks

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
  • You can escape the double-quote like so: `\"`. Or you can use literal strings (strings starting with `@`). – Branko Dimitrijevic Aug 06 '21 at 04:58
  • 1
    Does this answer your question? [Escape double quotes in a string](https://stackoverflow.com/questions/14480724/escape-double-quotes-in-a-string) – Isi Aug 06 '21 at 05:01

2 Answers2

2

You can use a 'verbatim identifier' (@) and escape quotes with double quotes.

Note that you can also combine the 'string interpolation identifier' ($) so that you're not building up the string with pluses. See:

https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/verbatim

and

https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/tokens/interpolated

Then you could write your code something like:

var myString = @$"QUESTID = LuaGetQuestID(""{textBox1.Text}"")";
Jonathan
  • 4,916
  • 2
  • 20
  • 37
0

thanks, guys it works with this code

File.Write("  QUESTID = LuaGetQuestID(" + '"' + textBox1.Text + '"' + ")\r\n");