In Visual Studio 2015, when I move on to writing an interpolated string in a variable by entering the opening braces '{', to achieve the following:
var a = $"{}";
the second end bracket is automatically inserted, painted red or pink, so that
var a = $"{}}"
After inserting the variable inside the brackets '{}' and trying to compile, Visual Studio throws an error: "Character CS8086: A" should be escaped (by doubling) in the interpolated line. ". It makes sense, but doesn’t at all explain why the second“! ”Appeared first! I didn’t want to write the alphabetic character '}'; I just wanted to write a regular interpolated line - one '}' for one '{'. Each time when I use interpolated strings, I am forced to manually remove this anomalous second closing bracket for successful compilation.
Most curious, it seems that this is not all the time. If you remove "{}}" from your interpolated string and type "{" again, you will get "{}" - just like you expected in the first place.
What about this behavior?
c # visual-studio-2015
lordmilko
source share