❔ multi-line strings
hi, if I have a string like
when my code is formatted, tabs get inserted into my string so it ends up like:
What is the best way around this? replacing new lines with
\n
?13 Replies
You can use a raw string literal (new feature in C# 11):
is it safe to set my language version to C# 11 preview? (still on .net6)
upgrade to 7
i guess i need to for this - just cant be bothered right now cuz i gotta update and re-test my docker deploys
its on my plate for later in the week though
well for now you can just not indent
There are features in C# 11 that require .NET 7 (namely
ref
fields IIRC), but if you are careful about what you use it should still work fine (I'm even using C# 11 in a .NET 5 project)ive currently got "\n" in my string and keeping it on a single line, i think that might work ok
oh right you can actually set the lang version to 11
Yup, it's technically unsupported, but as long as you are careful not to use any features that require runtime changes it works perfectly fine
i saw 11 in the dropdown in Rider but assumed latest preview would be the same or better
I don't believe there's anything newer than 11 at the moment
Usually it's best to stick with a specific lang version, rather than using preview
Preview is the absolute latest, and may have features that get changed later in development
An update from .NET 6 to .NET 7 is really as simple as just changing the version in the csproj
Same for the language version
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.