Home > Software design >  How to use string builder to make command for cmd to include value from variable?
How to use string builder to make command for cmd to include value from variable?

Time:04-29

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}.

CodePudding user response:

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

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

c# online

  • Related