Тёмный

.NET 7 Update: Raw String Literals in 10 Minutes or Less 

IAmTimCorey
Подписаться 415 тыс.
Просмотров 10 тыс.
50% 1

Raw string literals are here in C# 11. And while they look wild, they actually have a good reason for existing. Let's see them in action in this 10-Minute Training video.
Full Courses: www.iamtimcorey.com
Source Code: leadmagnets.app/?Resource=Raw...
Mailing List: signup.iamtimcorey.com/

Опубликовано:

 

20 ноя 2022

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 55   
@charlesbyrne71
@charlesbyrne71 Год назад
I needed this 2 years ago lol. The workaround was tokenization and string replacement. String substitution wasn't ideal, but it was a limited use case. I added comments and attributes around the methods to indicate why I did it at the time. We haven't had to visit that code area since implementation, but this would have made things so much easier.
@johnnysong9781
@johnnysong9781 Год назад
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.
@IAmTimCorey
@IAmTimCorey Год назад
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.
@Dultus
@Dultus Год назад
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!
@IAmTimCorey
@IAmTimCorey Год назад
Agreed.
@saintinel
@saintinel Год назад
Finally! I was waiting for it, years now :)
@IAmTimCorey
@IAmTimCorey Год назад
Excellent!
@dasfahrer8187
@dasfahrer8187 Год назад
Doug DeMuro approves of this quirks and features video for .NET 7 raw string literals.
@theobellash6440
@theobellash6440 Год назад
Learned something new… Thanks for posting
@IAmTimCorey
@IAmTimCorey Год назад
You are welcome.
@Wambie68
@Wambie68 Год назад
Thanks. Just the tip I needed
@IAmTimCorey
@IAmTimCorey Год назад
Thank you!
@HimalayanNavigator
@HimalayanNavigator Год назад
Thanks Tim, vey nice information 🙏
@IAmTimCorey
@IAmTimCorey Год назад
You are welcome.
@Lomunist
@Lomunist Год назад
Thanks Tim!
@IAmTimCorey
@IAmTimCorey Год назад
You are welcome.
@ShuklaAayushi
@ShuklaAayushi Год назад
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. 👍
@IAmTimCorey
@IAmTimCorey Год назад
Glad it was helpful!
@simon-white
@simon-white Год назад
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.
@IAmTimCorey
@IAmTimCorey Год назад
You are welcome.
@ABMedia83
@ABMedia83 Год назад
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.
@IAmTimCorey
@IAmTimCorey Год назад
Thanks!
@ibrahimlita66
@ibrahimlita66 Год назад
Thanks bro. useful knowledge .
@IAmTimCorey
@IAmTimCorey Год назад
You are welcome.
@AzDev-CommV
@AzDev-CommV Год назад
Thanks for your effort! 😀
@IAmTimCorey
@IAmTimCorey Год назад
You are welcome.
@sivasworld4632
@sivasworld4632 Год назад
Good info Tim😉
@IAmTimCorey
@IAmTimCorey Год назад
You are welcome.
@kahbreeezyy
@kahbreeezyy 10 месяцев назад
Great video, thanks for sharing! 😅
@IAmTimCorey
@IAmTimCorey 10 месяцев назад
You are welcome.
@mrsajjad30
@mrsajjad30 Год назад
great lesson.
@IAmTimCorey
@IAmTimCorey Год назад
Thanks!
@mokshaGyanRam
@mokshaGyanRam Год назад
great man thanks it would be very helpful in json parsing and connections pulling.. thanks for tiip
@IAmTimCorey
@IAmTimCorey Год назад
You are welcome.
@ahlinn6809
@ahlinn6809 Год назад
Thanks for sharing new!
@IAmTimCorey
@IAmTimCorey Год назад
You are welcome.
@goodmanshawnhuang
@goodmanshawnhuang Год назад
Thanks a lot Tim, seems I don't have to use string template4 anymore?
@williamliu8985
@williamliu8985 Год назад
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.
@IAmTimCorey
@IAmTimCorey Год назад
It is a C# 11 feature. C# 11 is only supported on .NET 7, but some things can be brought back to previous versions.
@williamliu8985
@williamliu8985 Год назад
@@IAmTimCorey Great! Is there a list saying which features can be used in previous .Net version? Just curious.
@crogongrey4549
@crogongrey4549 Год назад
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. 👍
@IAmTimCorey
@IAmTimCorey Год назад
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.
@theMagos
@theMagos Год назад
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?)
@IAmTimCorey
@IAmTimCorey Год назад
You could use a raw string literal there, or you could use two double quotes ("") or you could escape it (\").
@hqcart1
@hqcart1 Год назад
Finally, the worst thing in C# is fixed for good!
@IAmTimCorey
@IAmTimCorey Год назад
I'm glad you are going to enjoy it.
@jhonatanjacinto
@jhonatanjacinto Год назад
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.
@IAmTimCorey
@IAmTimCorey Год назад
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.
@jhonatanjacinto
@jhonatanjacinto Год назад
@@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.
@micro2743
@micro2743 Год назад
Great Video, but I think I porefer the old way.
@IAmTimCorey
@IAmTimCorey Год назад
The old way? You mean with the doubling up of double quotes, etc.? Can I ask why?
@f.donnet8165
@f.donnet8165 Год назад
@@IAmTimCorey It is impossible to prefer the old way. :) That's a game changer. Even for unit testing a jsonstring etc etc.
@Gabeyre
@Gabeyre Год назад
What a confusing way to do simple string manipulation.
@den3v
@den3v Год назад
Cool
@IAmTimCorey
@IAmTimCorey Год назад
Thanks!
Далее
BU KUN | THIS DAY
00:28
Просмотров 4 млн
Intro to Regular Expressions - How to use Regex in C#
55:52
3 Ways Every Developer Fails And How To Avoid Them
26:16
Liskov: The Liskov Substitution Principle
4:23
Просмотров 19 тыс.
Strings in C# 11 just got a whole lot better
11:02
Просмотров 77 тыс.
Working with Null in .NET 6 and C# 10
57:26
Просмотров 35 тыс.
C#11 - Raw String Literals
7:05
Просмотров 1,3 тыс.
How Regex got so much faster in .NET 7
9:36
Просмотров 38 тыс.
BU KUN | THIS DAY
00:28
Просмотров 4 млн