Every feature added in C# 10 with examples

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

Hello everybody I'm Nick and in this videoI will show you every single feature added in C# 10.

Timestamp:
Intro - 0:00
Global using statements - 0:17
File scoped namespaces - 2:30
Constant interpolated strings - 3:37
Attributes support generics - 4:37
Lambda improvements - 5:31
Extended property patterns - 7:20
Record structs - 8:35
Record types can seal ToString() - 9:53
Structure type improvements - 10:48
Assignment and declaration in the same deconstruction - 11:53
Allow AsyncMethodBuilder on async methods - 13:05
Static abstract members in interfaces - 14:19

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

Social Media:

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

Thank you so much everyone for pointing out usecases for static abstract members in interfaces. No idea how I missed it, since it's quite obvious but I'm so glad you could give me a hand wiht this one!

nickchapsas
Автор

I love it that you if you don't know a mechanism you just say "I don't know it, but just wanted to tell you that something will be changed."! Thank you for presenting C# 10 features in this nutshell :)

Krzysztof
Автор

Static abstract members are Typeclasses from Haskell. When implementing an interface you need to extend from it in the class declaration (class X : Interface { }), but with this new feature you can extend classes which you don't control (like extension methods, but in a controlled manner). This goes WAY beyond "numerical" code.

For example, a while ago I was working on an Android project that used the class "MediaMetadataRetriever". In order to use the "try-with-resources" construct, a class should implement the "AutoClosable" interface. The class didn't implement the interface until API 29. Even if the class conformed to the interface and I could recreate the behavior using it's public API the only option I had was to make a subclass that implements it. With Typeclasses I could easily extend the interface without needing to control the class implementation.

valcron-
Автор

So happy about the static abstract members. This is something that has been bugging me for years. I have needed this feature many times and no language ever seemed to have it.

Without this functionality, if you want a class family to have common fields with hardcoded values, but with different values for each subclass, you have to instantiate the class before you can access the hardcoded fields. Now you can just call it statically from the subclass. I feel like I often want this functionality when associating enums with subclasses. You can also enforce singletons in a class hierarchy with this.

victorvandermilte
Автор

I've been coding in Typescript only for the last 6 months, came here to check on my favortie language and your video made me keen to get back to C#

lahcencodery
Автор

Unless I've missed it in your videos, a video on Func and Action with practical use cases would also be great!

RoughSubset
Автор

For me, the file scoped namespaces, global usings & lambda improvements are the greatest additions to the language. The only thing that Java language had better than C# was the package system; now with file scoped namespaces, I declare the Java language officially defeated. Everywhere, the C# syntax is now cleaner, shorter & more powerful. (Note that this is relevant to the Java as the language, the ecosystem has Clojure & Groovy languages which are both great.)

janbodnar
Автор

So I subscribed to many YouTubers... You are the first one who got the Notificaton Bell... Great work! A ton of useful information in a short amount of time.

MaxBenn
Автор

'AssAndDeclaration' from feature 9.
You are a master of naming! )

igorsentrxigorsentrx
Автор

Great video! My favourite is Filescode namespaces, it'll just make every day work so much nicer.

A quick tip on VS and SMSS (and some other editors/IDEs that want the same keybindings): Ctrl+K, C comments code (line if nothing is marked, marked code otherwise), Ctrl+K, U uncomments code (active cursor location and out).

hoej
Автор

They did some really nice work on this version of C#. I particularly liked the decreased amount of nesting and clutter caused by namespaces and using statements. I feel like this is revolutionary in terms of code-overview in C#!

Great video by the way, I subscribed!

SPLNTER_SE
Автор

Great video as always and thank you. Just taking some time to blow some smoke up your backside: it's really refreshing to hear on the last point, "I can't think of a use for this let me know if you can..." it's the tendency of a lot of big programming YTers to be incredibly patronising and thinking they have to know everything. I'm only amateur but find a lot of channels talk down to their viewers even on complex subjects. Your approach is much more level-headed and you don't talk down to your viewers which I appreciate and will cause me to continue watching and staying subbed. Cheers.

ajonescouk
Автор

The abstract members in an interface, I was just wishing the other day I could do that in a game I have been working on. Nice to see that I will soon be able to. 👍

mosthed
Автор

I'm happy to see F# features still flowing to C# by the bucket. Can't wait to have them back while working with C#. :)

Static abstract might even be better in some cases than the explicit inlining chaos F# has been using.

Now do type providers and tail recursion and units of measure. lol

VandroiyIII
Автор

Been waiting on generic attributes for sometime; good to see it implemented, now hoping for static indexers

moeb
Автор

C# 10 has really great code-reducing features, however, the static abstract members feature ups the game. Yes, it does allow for something like strong units does in F#, however, it also gives you a way to implement a Factory Pattern without having to declare a separate class. This means, one less level of complexity, and factories really make it easier to use immutable types, which means less bugs and easier-to-use libraries.

jors
Автор

The last one is so amazing!! I've been waiting for something like this to be added, I'm seriously excited for this! It easily outshines the other changes, even though it is still in preview. The *with* keyword on structs as well as record structs are a close second - I already knew about those, but finding out we are getting what is pretty much Typeclasses has just really made my day, can't wait!

petrusion
Автор

I'm disappointed the "field" keyword for properties didn't make the cut for C# 10. It would have let me get rid of so much cookie cutter code when I work WPF.

TrowGundam
Автор

File scoped classes would also be great, possibly that get class name from file name.

SecondFinale
Автор

Thanks a lot, Nick! A very nice overview.

dmytroshchotkin
welcome to shbcf.ru