Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Double Block Quote with String not working

I have tried to insert a dynamic string in a static string with double quote, also tried How to add double quotes to a string that is inside a variable? but nothing work in my case:

startInfo.Arguments = @"/C = """+service+""" >nul 2>&1";

service is dynamic string and i need this result:

"/C = "mystring" >nul 2>&1";

Without dynamic variable i use double quote and it work, and i need @ for static Path

"/C = ""static"" >nul 2>&1";

enter image description here

like image 858
Marcus J.Kennedy Avatar asked Dec 30 '25 03:12

Marcus J.Kennedy


1 Answers

The verbatim string only applies to the first part because you are concetanating with +, you can try using string interpolation:

startInfo.Arguments = $@"/C = ""{service}"" >nul 2>&1";
like image 193
Selman Genç Avatar answered Jan 01 '26 18:01

Selman Genç