Jake M Jake M - 2 months ago 11
C# Question

How do I interpolate strings?

I want to do the following in C# (coming from a Python background):

strVar = "stack"
mystr = "This is %soverflow" % (strVar)


How do I replace the token inside the string with the value outside of it?

Answer
string mystr = string.Format("This is {0}overflow", strVar);

And you could also use named parameters instead of indexes.