8

With the existing String.Format, I could throw the format string in a database or resource file, instead of having it hard coded into my application. Is that possible with Interpolation?

I'm guessing not, as it seems to be a compiler checked thing.

1 Answer 1

12

No, it's a compiler thing as this:

string result = $"{name}";

Is compiled into this:

string result = string.Format("{0}", name);

And you can't run the compiler on these stored strings.

You can store the strings with the numbered parameters though, and use string.Format explicitly.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.