Do you use string interpolation when formatting strings
  v1.0 Posted at 29/01/2020 4:36 PM by Liam Elliott
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: Bad Example - Using String.Format() makes the code difficult to read

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

Figure: Good Example - String Interpolation is very human readable

Related rules

    Do you feel this rule needs an update?

    If you want to be notified when this rule is updated, please enter your email address: