The New Way of Parsing ANY Type in .NET

preview_player
Показать описание

Hello, everybody, I'm Nick, and in this video, I will show you a really cool feature that was added in .NET 7 that allows you to parse strings into any type with a consistent interface and programming model.

Don't forget to comment, like and subscribe :)

Social Media:

#csharp #dotnet
Рекомендации по теме
Комментарии
Автор

All of the new "generic math" interfaces are awesome - long overdue. But please - DON'T implement TryParse as a call to Parse inside a try-catch. One of the key benefits of TryParse is that it does not throw - even internally. Implement Point2d.TryParse as two calls to int.TryParse and return true only if both succeed - no throw/catch inside.

carldaniel
Автор

Question: is there something built in that can do fixed width? Currently i have to do a lot of specific span reads but if there was a range like you had that i could split based upon multiple indexes then that might be better

T___Brown
Автор

just curious, what are you beginning to type when you are setting a default parameter? You start typing `format = by`, but then you backspace and type null. You did it twice haha

theonlywallrus
Автор

Meh. Kinda cool, but ultimately not terribly useful, because types rarely only have one string representation.

If you want to create a different type for each representation, I guess this would work, but it just seems that writing a static parse function would be quicker and easier to understand.

But we’ll see. Maybe I’m just getting old, but adding new language features every month or two seems a bit chaotic, I think. You can’t even start and finish a project before your code is already obsolete. 🙄

AftercastGames
Автор

Nice. In the ReadOnlySpan TryParse example. Shouldn't it return false instead of throwing ArgumentOutOfRangeException?

ntohl
Автор

When MS said they will add static interface members, I thought, they lost they mind. But now, that they provided such use cases, I'm changing my opinion :-)

woocaschnowak
Автор

Understood everything up to 2:00. After that my brain went coo-coo!

zoran
Автор

10:11 We're circling right back to pre-2000s C, haha

mariocamspam
Автор

we used to use Convert.ChangeType() for primitive data types. now we are changing the implementation to IParsable<>. its pretty neat.

quranthecompanion
Автор

"Random number"
Casually type in "69"
😂😂

tmcheah
Автор

The span part is imo way more interesting than the interface and abstract static stuff

hanspetervollhorst
Автор

I wonder why it's not spelled IParseable like ICloneable?

EdKolis
Автор

I really like the new Span splitting method, makes me feel in control of my memory. Also i totally love the new abstract interfaces, especially the IParsable, but I probably used INumber a lot more already.

cn-ml
Автор

Does somebody know if Complete Nick Chapsas Course Bundle will get all future courses? Please ☺ I'm thinking of buying it...

DaliborHomola
Автор

Nice. Wouldn't call that extension "Parse" though, since the string isn't parsing, it's being parsed.

gunnarliljas
Автор

I very much like this feature, I would rather prefer the "shapes" approach but this is really very very very userful

diadetediotedio
Автор

A type should not implement its own serialization.

pufferfish
Автор

This was a great blend of useful right now, interesting and showing future functionality. Kudos!

SvdSinner
Автор

When Nick says Random number it means always 69

ONESTTEFTEO
Автор

Hey Nick, I saw you yesterday at Techorama. Thanks for the great talk!

haveaniceday