GenesysFramework.com

$”” string interpolation condenses .NET string.Format()

String interpolation is available via dollar sign $, and it makes code much more readable. For example:

var dateMessage = $"Current date is: {DateTime.UtcNow}";

Or a more in-depth example, unrolling SqlParameter nvarchar values

            foreach (var item in Parameters)

            {

                var commaSeparator = sqlStatement.Contains("@") ? "," : "";

                sqlStatement = $"{sqlStatement}{commaSeparator}{item.ParameterName} = '{item.Value}'";

     }

Happy Coding!

Leave your comment