ReSharper 2024.1 Help

Code inspection: Use string interpolation expression

Category

Language Usage Opportunities

ID

UseStringInterpolation

EditorConfig

resharper_use_string_interpolation_highlighting

Default severity

Suggestion

Language

C#, VB.NET

Requires SWA

No

Starting from C# 6.0, you can use string interpolation expressions instead of calling String.Format(). If you pass a lot of arguments to the String.Format() method, the string becomes difficult to understand. Compared to String.Format(), interpolated string expressions allow inserting variables directly in the string.

var greeting = string.Format("Hi {0}! How do you feel at {1}?", name, location);
var greeting = $"Hi {name}! How do you feel at {location}?";
Last modified: 08 April 2024