I mean, that looks really weird but I know I'm gonna love this! I sometimes have troubles with building patterns in Regex I copied from a builder like Regexr, so I can throw it in like that. Thank you very much!
Things are in fact becoming more complicated as they appear simpler. Over time, we'll need to refactor all the string processing techniques to make life easier.
I'm not sure that this is the case. This is more of a "you now have more and better options". When I first started working with electrical, I had just a couple tools. As I started doing more of it, my toolbox became more "complicated". That isn't a bad thing. It means I have more specialized tools to do certain jobs more easily. If a new person were to start working on electrical items, they could start out with just a few tools. The same is true for C# developers - when you are getting started, you don't need to use all of the tools available to you. I teach only a couple solutions for strings, for example (@ and $). Then, as you become more accustomed to those tools, you can add more options.
Great video, I can see this being very useful generating specific file types properly (aka CSS, HTML, JavaScript, Python, etc) without a bunch of boilerplate code.
Nice, was recently wanting something like this. Similar to Here-Strings in PowerShell with a bit of a clunkier implementation but more flexibility with the indent. Thanks for these updates.
I have a question, does this "Raw String Literals" feature from c#11 or .net 7? Looks I can use it in a net6 project with setting the LangVersion to preview. I am a bit confused between the .net version feature and the c# language version feature.
I really wish there was a compiler option or something to enable this for older versions of .NET. I write so much stuff with little SQL and other non-C# code snippets for .NET Framework 4.8 (external requirement; can't be helped). So far I've always just put it as a verbatim literal but I'm constantly fighting with colleagues about the formatting. Their solution is to put every line of foreign code as a separate string then a + Envrionment.NewLine + at the end and then the next line. I mean yes everything is correctly indented now but it's sooo impractical. Especially if you want to copy things back and forth between editors and the IDE. And if I indent my verbatim literals I am now the forever keeper of the correct indentation of that bit of code and it's a pain to read while debugging. Anyway, great video. 👍
Yeah, that is a pain. Unfortunately, they aren't changing the .NET Framework anymore so no new features for you. Hopefully your external requirements will be changed eventually.
Not neccessarily related to raw string literals, but if the "level" string contains a quotation character ( " ) how do you properly encode it? (some helper function?)
I think it's just too messy to work with. Whatever the situation I may find myself thinking of working with it I'll definitely try another solution... Hahaha.
Why is this too messy? As for another solution, what would that look like? If you use the previous solution, it would mean doubling up every double quotes character and not being able to do string interpolation if you have curly braces in your string already. That's messy.
@@IAmTimCorey What I mean is: do I REALLY REALLY need to put this JSON or whatever inside my code base ending up with this result? There's no other way around? That's how my code should really look like? This is what I meant because just seeing how messy it looks to me, it hurts...and I just wouldn't like to see it inside the structure of my code. Just that! Of course, if there's no other way and it's REALLY required... ok, but I'll try as hard as possible to avoid such scenarios.
Thanks. Just the tip I needed
Thank you!
Finally! I was waiting for it, years now :)
Excellent!
I mean, that looks really weird but I know I'm gonna love this!
I sometimes have troubles with building patterns in Regex I copied from a builder like Regexr, so I can throw it in like that.
Thank you very much!
Agreed.
Things are in fact becoming more complicated as they appear simpler. Over time, we'll need to refactor all the string processing techniques to make life easier.
I'm not sure that this is the case. This is more of a "you now have more and better options". When I first started working with electrical, I had just a couple tools. As I started doing more of it, my toolbox became more "complicated". That isn't a bad thing. It means I have more specialized tools to do certain jobs more easily. If a new person were to start working on electrical items, they could start out with just a few tools. The same is true for C# developers - when you are getting started, you don't need to use all of the tools available to you. I teach only a couple solutions for strings, for example (@ and $). Then, as you become more accustomed to those tools, you can add more options.
Doug DeMuro approves of this quirks and features video for .NET 7 raw string literals.
Thanks Tim!
You are welcome.
Great video, I can see this being very useful generating specific file types properly (aka CSS, HTML, JavaScript, Python, etc) without a bunch of boilerplate code.
Thanks!
Nice, was recently wanting something like this. Similar to Here-Strings in PowerShell with a bit of a clunkier implementation but more flexibility with the indent. Thanks for these updates.
You are welcome.
Learned something new… Thanks for posting
You are welcome.
This is super helpful! Thanks a ton for such simple explanation. I was honestly too baffled to understand when I first started reading up on it. 👍
Glad it was helpful!
Good info Tim😉
You are welcome.
Thanks Tim, vey nice information 🙏
You are welcome.
Thanks for your effort! 😀
You are welcome.
Thanks bro. useful knowledge .
You are welcome.
great lesson.
Thanks!
Great video, thanks for sharing! 😅
You are welcome.
I have a question, does this "Raw String Literals" feature from c#11 or .net 7? Looks I can use it in a net6 project with setting the LangVersion to preview. I am a bit confused between the .net version feature and the c# language version feature.
It is a C# 11 feature. C# 11 is only supported on .NET 7, but some things can be brought back to previous versions.
@@IAmTimCorey Great! Is there a list saying which features can be used in previous .Net version? Just curious.
Thanks for sharing new!
You are welcome.
great man thanks it would be very helpful in json parsing and connections pulling.. thanks for tiip
You are welcome.
Thanks a lot Tim, seems I don't have to use string template4 anymore?
I really wish there was a compiler option or something to enable this for older versions of .NET. I write so much stuff with little SQL and other non-C# code snippets for .NET Framework 4.8 (external requirement; can't be helped). So far I've always just put it as a verbatim literal but I'm constantly fighting with colleagues about the formatting.
Their solution is to put every line of foreign code as a separate string then a + Envrionment.NewLine + at the end and then the next line. I mean yes everything is correctly indented now but it's sooo impractical. Especially if you want to copy things back and forth between editors and the IDE.
And if I indent my verbatim literals I am now the forever keeper of the correct indentation of that bit of code and it's a pain to read while debugging.
Anyway, great video. 👍
Yeah, that is a pain. Unfortunately, they aren't changing the .NET Framework anymore so no new features for you. Hopefully your external requirements will be changed eventually.
Not neccessarily related to raw string literals, but if the "level" string contains a quotation character ( " ) how do you properly encode it? (some helper function?)
You could use a raw string literal there, or you could use two double quotes ("") or you could escape it (\").
Finally, the worst thing in C# is fixed for good!
I'm glad you are going to enjoy it.
I think it's just too messy to work with. Whatever the situation I may find myself thinking of working with it I'll definitely try another solution... Hahaha.
Why is this too messy? As for another solution, what would that look like? If you use the previous solution, it would mean doubling up every double quotes character and not being able to do string interpolation if you have curly braces in your string already. That's messy.
@@IAmTimCorey What I mean is: do I REALLY REALLY need to put this JSON or whatever inside my code base ending up with this result? There's no other way around? That's how my code should really look like? This is what I meant because just seeing how messy it looks to me, it hurts...and I just wouldn't like to see it inside the structure of my code. Just that! Of course, if there's no other way and it's REALLY required... ok, but I'll try as hard as possible to avoid such scenarios.
Great Video, but I think I porefer the old way.
The old way? You mean with the doubling up of double quotes, etc.? Can I ask why?
@@IAmTimCorey It is impossible to prefer the old way. :) That's a game changer. Even for unit testing a jsonstring etc etc.
What a confusing way to do simple string manipulation.
Cool
Thanks!