Jake M Jake M - 11 months ago 58
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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download