Interpolated string - Do string literals cause a performance overhead? #59016
-
To improve readability the MSDN tells me that I can use string literals and this will be concated at compile time so there is no performance penalty. My question is, is this also true for interpolated strings? For example: string text = $"{a} Historically, the world of data and the world of objects " +
$"{b} have not been well integrated. Programmers work in C# or Visual Basic " +
$"{c} and also in SQL or XQuery. On the one side are concepts such as classes, " +
$"{d} objects, fields, inheritance, and .NET Framework APIs. On the other side " +
$"{e} are tables, columns, rows, nodes, and separate languages for dealing with "; Will this get compiled the same as: string text = $"{a} Historically, the world of data and the world of objects {b} have not been well integrated. Programmers work in C# or Visual Basic {c} and also in SQL or XQuery. On the one side are concepts such as classes, {d} objects, fields, inheritance, and .NET Framework APIs. On the other side {e} are tables, columns, rows, nodes, and separate languages for dealing with "; And if not, which one performs better? |
Beta Was this translation helpful? Give feedback.
Answered by
stephentoub
Sep 13, 2021
Replies: 2 comments 2 replies
-
Beta Was this translation helpful? Give feedback.
1 reply
-
|
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
0x90d
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yes
https://sharplab.io/#v2:EYLgtghglgdgNAExAagD4AEBMBGAsAKHQGYACLEgYRIG8CT6zT1sAGEgWWwApm2I4yrEsAG8SAY1FCEUtgFMAlCQC8APjoNNAEgBE1CAF8SACSgBnAC4B7AE5RxEADaOAngIsALOSQDutxwgkVgBmJAgQFhAkEDCBnt5+NgFBoVbAAFZy4hZmJDokyBqa9LrUwEYeEABu3jBWFsJycjC+cs4ksBZyAOY2EXIIAHSCAOxgcja5iQDWHS0UAMRBNiQAauYArk4kAEIQZvZ5BUXFpeJGMYFOZlZzJADKAIoAMsskABqPGxMuwwDyLXiQRg3gOCG8EBs3nEVhg4jkAAcciQzBtxB5orksHIzAJ8oV8MUGKUEEY0plsriSMEoG0EFTYF47JE4XIBJcSIMAHIAUQAKiQAGJ9cYzEgAQQACgBJMz/QFeILxFZg7z4k7aPRyC5QkiRYCOHECGGODZgGBUmxWHxUurgqkcsyIyH9EiOGLdLbdHHU2xhOROWDdXxQTx5ADcJxOxEEbHYmB4Qn4seEsgkaZkKcUKnUhKJJFKhhM5msdgczjcesViWSITCESiHKBNcCdfJWWRZQq1Vq9UazVa7U6PT6XSGo3Gk18tlmsEoSz961R2z2B…