I want to interpolation in the middle of a string, but I cannot use String.Format
, because the string contains {}
curly brackets.
This is what I have tried so far:
string code = "(function(){var myvariable = $"{variableToBeInterpolated}"});"
Returns: ) expected ; expected
Edit: I tried the following snippet, the interpolation is now working, but the code is not executed in the browser.
"(function(){var myvariable=" + $"{myvariable c#}" + ")});"