Randomness from an IT eclectic in Boston Mass: Kat's Microblog

Adventures in Programming when I should be sleeping

In light of string interpolation…why in the world would anybody want to use another method of writing code in the C# language? Placing a dollar sign before your output, and then simply placing the variable names inside of curly braces? Much easier than having to fart with the Console.Write() method. So, if you have the following:

decimal temperature = 44F;
Console.WriteLine($"the temperature is {temperature}");

Your application would deign then to respond with "The Temperature is 44F". There's another way you could write that code, using a lot more Console.WriteLine() statements, and then sticking the variable name in parentheses on a line between the lines of text...but why do that? Interpolation is much easier. People sometimes don't necessarily understand my choice in programming languages, but I picked C# as a good readable language. What are your thoughts?

Copyright 2021 by Katherine M. Moss All content on this site is CC BY 4.0