Rant on building strings in C#
Okay, I’ve inherited a codebase with no shortage of embedded strings, but there is one thing driving me batty.
string strSomething = "The Hungarian Notat" +
"ion is bad enough.\r\n " +
"but building the string" +
" like this is terrible" +
" and annoying to look at.";
string something = @"The Hungarian Notation has been fixed.
And the embedded string is less terrible and slightly less annoying to look at.";
It’s really just a readability thing, I don’t think it affects performance one iota. But looking at it is like walking with a pebble in your shoe. Annoying and it slows you down.
PS. I noticed the the source code highlighter picks out keywords everywhere. It’s just a hiccup in the formatter nothing to do with the actual code snippet.