0

I have tried so much but so far unable to produce a string like this using c#

Sku_id("5ac5d5fd754bc84f45786dd6")

I am trying to do something like this but unable to get the desired result, can anyone suggest what should I do.

var skuCode = "5ac5d5fd754bc84f45786dd6";

var skuId= "sku_id(" + '\u0022' + skuCode  + '\u0022' + ")");

The above code always produces the string like this which is not what I want

"sku_id(\"5ac5d5fd754bc84f45786dd6\")"

I want to produce a string and write to a text file like this

sku_id("5ac5d5fd754bc84f45786dd6")

Shax
  • 4,207
  • 10
  • 46
  • 62
  • How are you observing the string? In the debugger or in the actual file? The debugger will add slashes to inform you that it's an actual quote character and not the end of the string (ans makes it handy for copy/paste operations). – D Stanley Mar 20 '20 at 17:01
  • You can also do `var skuId= @"sku_id("""+ skuCode + @""")");` but the view in the debugger will be the same – D Stanley Mar 20 '20 at 17:02
  • Actually that code wont compile... – Trevor Mar 20 '20 at 17:04
  • 1
    Try this: `var skuId = "sku_id("\"" + skuCode + "\")";` – Oguz Ozgul Mar 20 '20 at 17:05
  • Try something like this: `var skuId= $"sku_id(\"{skuCode}\")";` – Barns Mar 20 '20 at 17:05
  • Your code is fine, remove the extra `)` at the end of `skuid` ... D Stanley mentions its the debugger that does this... – Trevor Mar 20 '20 at 17:06
  • Guys, what ever I do, in the text file it is writing the string along with "\" which is really I am not looking for. – Shax Mar 20 '20 at 19:15

0 Answers0