Search code examples
c#string-interpolation

How to use string builder to make command for cmd to include value from variable?


I need to create a string command for cmd, it already uses ${serverip} so I cant use string interpolation. Any suggestions?

string command = "tftp ${serverip}:/nfs/{MY_VALUE}";

I cant use:

string command = $"...";

It will read ${serverip}.


Solution

  • We can try to use double curly-brackets {{ to escape from Interpolated Strings

    string command = $"tftp ${{serverip}}:/nfs/{MY_VALUE}";
    

    c# online