Do you use string interpolation when formatting strings

Loading last updated info...

String Interpolation - greatly reduces the amount of boilerplate code required when working with strings Formatting strings on the fly was previously a task which required a stack of boilerplate code

var s = String.Format("Profit is ${0} this year", p.TotalEarnings - p.Totalcost);

❌ Figure: Figure: Bad Example - Using String.Format() makes the code difficult to read

var s = "Profit is ${p.TotalEarnings - p.Totalcost} this year";

✅ Figure: Figure: Good Example - String Interpolation is very human readable

Categories

Authors

Need help?

SSW Consulting has over 30 years of experience developing awesome software solutions.

We open source.Loving SSW Rules? Star us on GitHub. Star