Jake M Jake M - 4 months ago 18
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 Source
string mystr = string.Format("This is {0}overflow", strVar);

And you could also use named parameters instead of indexes.