Every single feature added in C# 11

Поділитися
Вставка
  • Опубліковано 18 гру 2024

КОМЕНТАРІ • 188

  • @barmetler
    @barmetler 2 роки тому +14

    My god, I can't even imagine how people even _compare_ java to this language. C# is on an entirely different level. There are things in C#11 where the developers of java don't even know what they are.
    My boss absolutely loves Java and it's so frustrating. We don't have access to generics (T.class, instanceof, new, etc), no operator overloading, no extension methods, no namespaces, no value types, everything has to be boxed, all function calls are virtual, it doesn't compile to actual machine code, there are no properties, no pattern matching, no nameof, no spans, no linq query syntax, no async/await, no generator functions, no partial classes, records were an afterthought that don't really help anything, reflection is half as powerful, no assembly-level visibility, no linq expression tree compilation, I could go on for hours.
    string interpolation, better string literals, dynamic type (for easier reflection), multiple generic classes with the same name but different generic count, no tuples, no named tuples, no initialization statements, no references, no top level main function, functions aren't first-class members, no local functions, just one class per file,

  • @Integer0
    @Integer0 2 роки тому +47

    You missed one interesting feature: you can now declare ref fields inside a ref struct. So you can write a new type like Span etc

  • @umilmi81
    @umilmi81 2 роки тому +18

    I have purchased courses from both Nick Chapsas and Tim Corey and Nick's courses are head and shoulders above Tim's. Nick talks at normal speed in his courses, provides the source code to follow along, and goes deep into the technical details of the topic. The courses are priced the same as a good book. They are a great value. Looking forward to more courses. I'd love a course on CI/CD with Azure and good NuGet package making practices.

    • @TheFeaz
      @TheFeaz Рік тому

      This is an interesting contrast between these two content developers (Nick and Tim). I've kind of made the same observation myself, and I'm curious to know what it is about Tim's courses and content that you don't like? I'm a content creator myself and looking to develop some courses as well from my perspective and experience (25 years) as a .net developer. It's the first public critique of Tim's content I've seen so I'm curious to know if any other developers make the same observations I have.
      FULL DISCLOSURE: I'm not trying to incite unfair criticism of Tim or his content. One thing I will say is that this space is big enough for multiple content providers, and different people learn differently. I like Nick's content personally because the cadence works well (for me) as an experienced developer who wants to get down to the nitty-gritty of how it works.

  • @NicholasReaves
    @NicholasReaves 2 роки тому +18

    Generics on attributes and required members are what I am personally looking forward to.
    I can write cleaner OO code that end users are less likely to be able to misuse :)

  • @justinian.erdmier
    @justinian.erdmier 2 роки тому +2

    My favorite new feature is the required' keyword with the new raw string literals as a close second. As someone who doesn't really write library/package code, only front-end consumed code, the other features don't really apply; but I love the work that the C# design team has done!

  • @foamtoaster9742
    @foamtoaster9742 2 роки тому +5

    This video is truly awesome. The perfect amount of detail to understand what the features do without making it way too long.

  • @dlhsnbrn1275
    @dlhsnbrn1275 2 роки тому +22

    static abstract interface members are my favorite by far. I cannot count how many times I thought "this code would be much nicer if this was possible".
    Second is raw string literals, because I have tons of tests that need constant XML or JSON values.

  • @olivervalienteoliva4335
    @olivervalienteoliva4335 Рік тому

    This video was an impressive introduction to a lot of new features, most of this really wanted for the community. Amazing video, thanks you for sharing.

  • @diadetediotedio6918
    @diadetediotedio6918 2 роки тому +3

    I really do love list patterns for parsers, a very useful feature

  • @tetheredsun950
    @tetheredsun950 2 роки тому

    Static abstract interface members, how long have I been waiting for you. The System.Numerics namespace is full of yummies.

  • @robertcahoon5278
    @robertcahoon5278 2 роки тому +37

    Awesome content. So useful. Any chance you can do similar summaries for earlier versions for those catching up? I find it incredibly useful in keeping up to date.
    Thanks again for such great content. 😎

    • @juergenzhang9133
      @juergenzhang9133 2 роки тому +11

      I had the same thoughts.
      It would be really great to have the whole C# development history in a series of such videos!
      Also thanks for this pearl of a compact video with lot of content.

    • @rankarat
      @rankarat 2 роки тому

      ua-cam.com/video/Vft4QDUpyWY/v-deo.html this is for C# 10

    • @rans0101
      @rans0101 2 роки тому

      Yes please, i was thinking the same

  • @diadetediotedio6918
    @diadetediotedio6918 2 роки тому +2

    21:30 The reason you need to initialize all values first is because structs are always located linearly in memory, and are not reset by default (as this has a performance cost), so C# gives you the opportunity to either use them without initialization default (and save a few nanoseconds, which can be relevant in extremely performance-hungry code), or initialize them all to ensure consistency

  • @TOMRUS88
    @TOMRUS88 2 роки тому +2

    ref fields and ref scoped are my favourites!

  • @DevonLehmanJ
    @DevonLehmanJ 2 роки тому +3

    I was really hoping that the `required` keyword had more use cases. I was thinking it'd be awesome if DI could use them for property injection- if the field is specified as `required`, then when the DI container tries to build the type, it should try to populate those values and throw if it doesn't have a registration for it. This would mean we could get rid of constructor injection which would be awesome!

    • @NoGamer256
      @NoGamer256 2 роки тому

      Well it depends whether you can check the field for required keyword using reflection API in .NET 7. Can you?

    • @marknn3
      @marknn3 2 роки тому

      @@NoGamer256 Yes, the compiler adds a RequiredMemberAttribute to the property

  • @CharlesBurnsPrime
    @CharlesBurnsPrime 2 роки тому +6

    This video is so useful as usual. A similar video demonstrating all new features of C#9, 10, etc. Would also be very useful. I can see that you like to focus on new features, but you would be surprised how many teams still use. NET all the way back to 4.0. Even Microsoft is still moving code from ancient releases.
    These many folks could use a series of such videos as a single point of reference as they transition.

  • @jongeduard
    @jongeduard 2 роки тому

    27:15 Well, why this is the case is quite understandable when you think about how a value type like a struct is stored: directly within the current scope, since no managed reference (pointer) in memory is made.
    Since you can never use an uninitialized variable in C#, it inevitably means that the struct has to be FULLY initialized before use, i.e. all fields must have been assigned with something. The compiler just wants to ensure this.
    Requiring you to assign it was needed, but assigning fields with a default value is also a solution. But it must be done in some or other way.

  • @gawiga
    @gawiga 2 роки тому

    Awesome summary! Save me a lot of time!

  • @buysmartter
    @buysmartter 2 роки тому

    Thank you for the videos. I found out about you a few weeks ago and since then I am watching all of your videos and enjoy them very much!

  • @nilscoussement
    @nilscoussement Рік тому

    This one video is worth so much for people who want to move to c# 11
    Thx a lot man, you helped me more then you can believe 😄

  • @stevekeith9507
    @stevekeith9507 Рік тому

    Great job Nick. I like 3 double quotes and pattern matching feature in C# 11 becuase they are "common man" features!

  • @meirkr
    @meirkr Рік тому

    The "required" keyword seems to be the most benefitial and to be used. Tx.

  • @nandkishorsonwale
    @nandkishorsonwale 2 роки тому

    Thanks for great video. My favourite features are list patterns, required member and pattern machining on spans...

  • @srd8580
    @srd8580 2 роки тому

    Great video, as always, Nick! Static abstract members by far will be my most-used feature here. I've wanted that more times than I can count going all the way back to .NET Framework days. The extended nameof scope will also be handy, my team ironically just attempted that the other day under C# 10 (obviously to no avail), so good to know it'll be there next time!

  • @AlexFeature
    @AlexFeature 2 роки тому

    Generic attributes are probably the coolest addition. Thanks for the vid Nick, awesome stuff as usual.

  • @RaistlanCE
    @RaistlanCE 2 роки тому +1

    Scoped (and ref fields), easily. A big addition to the ref/ref readonly/in parameter toolkit.

  • @Uebagi
    @Uebagi 2 роки тому

    7:45 this change alone is worth it for me. I have a writer to a nosql where i have a standardized data contract, before the Typing and params was overly complex and ugly. Now I can make my code way cleaner 😎

  • @Explorest
    @Explorest 6 місяців тому

    This was a great video as a one stop shop for every new feature in C#11 . I wonder whether you did something similar for C#12 ? This is a wonderful format for people who don't have time to get up to speed with a whole version update in C#.

  • @leondepaauw
    @leondepaauw 2 роки тому

    Thanks for another amazing video. I'll be using the raw string literals a lot and the file scoped types in some cases.

  • @VitaNova83
    @VitaNova83 2 роки тому

    Lots of exciting stuff. Required members are going to be so nice but I've been looking forward to list patterns since it was pushed right from the original pattern matching release.

  • @cdrbvgewvplxsghjuytunurqwfgxvc
    @cdrbvgewvplxsghjuytunurqwfgxvc 2 роки тому

    Woha, so ready for c# 11! Techempower benchmarks on the release blog post for net7.0. Love it. They became household name quickly

  • @lucaslinhares4071
    @lucaslinhares4071 2 роки тому

    I love your videos, I can always improve my projects with them + it's keeps me updated with every release.

  • @ArafatTehsin
    @ArafatTehsin 2 роки тому

    Love it Nick. Thanks for sharing it.

  • @dev-skills
    @dev-skills 2 роки тому

    Raw string literals very well explained.

  • @KingOfBlades27
    @KingOfBlades27 2 роки тому

    String changes will be so useful and needed. Also thanks for the video Nick! You are doing God's work here 💪

  • @francoislepron2301
    @francoislepron2301 2 роки тому

    Awesome video as usual, and I do appreciate this presentation of the new features as you did it with examples.

  • @josedejesusbarajaschavez1374
    @josedejesusbarajaschavez1374 2 роки тому

    Awesome video. I think at least the half of the new features will be useful for me, so let's see. Thanks Nick :)

  • @MrFaciio
    @MrFaciio Рік тому

    Amazing video, thanks for shortcut new features!

  • @mickecyborg
    @mickecyborg 2 роки тому

    Thank you for your content. I am working as a .NET developer primarily using VS2022 and have many times referred to your content as best practice. I would like to see a video how you have configured Visual Studio Code to be so fluent when running and debugging projects. What plug-ins are you using. How have you configured your environment?
    How do you configure VS Code to have the features you so fluently use in your videos?

  • @luanalbuquerque5073
    @luanalbuquerque5073 Рік тому

    This is the video that i was watting for

  • @TheTempterable
    @TheTempterable 2 роки тому

    Finaly! Interface for countable types!! Yes!!!

  • @sDiovliFR
    @sDiovliFR 2 роки тому +1

    Great video! On 21:46 you have IL Viewer, but it shows "High-Level C#". What plugin is that?

    • @nickchapsas
      @nickchapsas  2 роки тому +6

      It’s not a plug-in. It’s a new feature of Rider’s new version. It’s amazing!

  • @muhamedkarajic
    @muhamedkarajic 2 роки тому

    As usual to the point, clear. Great video!

  • @amuuuinjured
    @amuuuinjured 2 роки тому

    I will use Generic attributes and Required members. Maybe file scoped types will become handy too.
    Thanks, for video.

  • @HimmDawg
    @HimmDawg 2 роки тому +3

    I'm disappointed that semi-auto properties were not added in C#11 :( that was the feature I was looking forward to most

  • @alexclark6777
    @alexclark6777 2 роки тому

    Started using static abstract members on interfaces a couple months ago via the preview feature, but was looking forward to generic math becoming generally available - the combination of both has severely reduced boilerplate in a library I'm working on.
    Definitely looking forward to the 'scoped' video. I'm guessing it's something similar to lifetime annotations in Rust, albeit slightly more coder-friendly.

  • @kgnet8831
    @kgnet8831 2 роки тому

    list patterns (are also cool for pattern matching in switch), static abstract, string interpolation

  • @matthewlloyd3255
    @matthewlloyd3255 2 роки тому

    I was employed as a programmer for a bit more than a decade and use Java, Javascript and C# reasonably often. While all the many language features each of these languages have to offer is great - because I'm often porting programs between each of these 3 languages the featureset of the engines and code I write remains extremely simple. Almost everything I write is single threaded, uses only basic data types (floats, ints, strings and doubles), struct like objects and simple arrays of data types and structs/objects. I find that by limiting my code to only the most basic features of the language I can port from one to another extremely easily - plus my programs remain very simple to read and understand.

  • @F1nalspace
    @F1nalspace 2 роки тому +1

    Feature 7 is awesome and will save us a ton of headaches with our special signal math routines. We finally can drop that bad template generator code for our special number types and methods like Min/Max/Avg, etc.

  • @verzivull
    @verzivull 2 роки тому

    Nick, you're awesome!

  • @alexpaskal8345
    @alexpaskal8345 2 роки тому

    i was waiting for exactly this video!

  • @borsuk7667
    @borsuk7667 2 роки тому +2

    required keyword will be better if it'll be default for records
    So you can created record either by ctor or by object initializer

  • @xlerb2286
    @xlerb2286 2 роки тому

    Good video as always. Generic math would have been a big help to me at my prior job. Most of those look pretty useful though. No great "oh my gosh, this changes everything" features. But lots of little useful additions.

  • @renetittel17
    @renetittel17 2 роки тому

    Danke!

  • @Daanik8
    @Daanik8 2 роки тому

    Very good video! Thank you Nick

  • @Zainjerr
    @Zainjerr 2 роки тому

    This is exactly what I needed
    Thanks a ton mate!

  • @PanzerFaustFurious
    @PanzerFaustFurious 2 роки тому +1

    required keyword is definitely my favorite , just wish you could also do null/argument checking with auto-properties.

  • @geraldmaale
    @geraldmaale 2 роки тому +4

    happened to be idle, lets learn 😊

  • @diego_samano
    @diego_samano 2 роки тому

    Raw literals will be very useful for inline values when creating unit testing or initial setups and List patterns looks great. But .Net 7 is a great release with a bunch of cool features.

  • @MrIsrael3000
    @MrIsrael3000 Рік тому

    Raw string literals, patterns for numeric values, abstract math, scope for name of.

  • @Jochinator2
    @Jochinator2 2 роки тому

    Required members are my favorite new feature

  • @omarjuul
    @omarjuul 2 роки тому +1

    15:18 isn't it technically more correct to use `AdditiveIdentity` here? Is there ever a difference between `Zero` and `AdditiveIdentity`? Why did the design team add both?

    • @BodenUnits
      @BodenUnits 2 роки тому +1

      It is :)
      Well technically 'Zero' is a property that returns something that resembles our idea of 0 for any Implementation of the INumberBase interface. But not every construct that supports addition (by implementing IAdditionOperators) will also implement INumberBase. IAdditiveIdentity is its own interface (both implemented by INumberBase) as well. So you can define the addition operator and the additive identity without having to implement all number related things.
      Think of something like a matrix, you would not want to be in the position to implement the IsEvenInteger method on that, how would you answer that. But you could still implement IAdditionOperators and IAdditiveIdentity for a matrix class.
      Matrices are also an example where 'One' and MultiplicativeIdentity are usually not the same, since in my opinion 'One' should be a matrix with ones everywhere, whereas MultiplicativeIdentity is the Identity matrix with ones only on the main diagonal.
      TL;DR: if you just want to calculate a sum, you should restrict the generic type to IAdditionOperators and IAdditiveIdentity, and those only implement the + operator and AdditiveIdentity, not Zero

  • @nanvlad
    @nanvlad 2 роки тому +3

    Good video. Did they add keyword 'field' in this version to reduce private field declaration?

    • @nickchapsas
      @nickchapsas  2 роки тому

      The field keyword didn’t make it in the full release

    • @sanjayidpuganti
      @sanjayidpuganti 2 роки тому

      That was initially planned for C#11 but now it is planned for C#12

    • @MegaJoka100
      @MegaJoka100 2 роки тому +2

      @@nickchapsas That means no semi auto implemented properties? That's sad, was really looking forward to this.

    • @lordmetzgermeister
      @lordmetzgermeister 2 роки тому

      @@nickchapsas big sad

  • @TheOmokage
    @TheOmokage 2 роки тому +1

    Do we have the possibility to use the list patterns functionality without expressions using 'is' ? = ))For example like this:
    string[] people = { "Tom", "Bob", "Sam", "Kate", "Alice" };
    people[1..4 string[] firstToFouth, var fifth, .., var last];
    Console.WriteLine($" {fifth} {last}");

    • @TheOmokage
      @TheOmokage 2 роки тому

      Is there an analogue of this functionality? This looks like a better version of range and indexes

  • @danilonotsys
    @danilonotsys 2 роки тому

    Hi Nick. Would you be interested in making a video about the performance improvements in EFCore 7? Maybe with a comparison with Dapper and ADO?

  • @mariocamspam72
    @mariocamspam72 2 роки тому +2

    the notification got me excited

  • @Denmaverick39
    @Denmaverick39 2 роки тому +1

    Raw string literals for unit testing

  • @xavier.xiques
    @xavier.xiques 2 роки тому

    Good video, thanks Nick

  • @vorontsovru270895
    @vorontsovru270895 2 роки тому

    21:40 How did you make High-level C# display in IL Viewer?

  • @moditrix
    @moditrix 2 роки тому

    One of the projects I work on has a large number of unit tests that use static json as input, which I get from real data. Copying such strings as json is very annoying. So I will use raw string literals immediately and massively. Static virtual interfaces have been missing in C# for a long time. Required members is another feature that I very much welcome. And the last feature that I will definitely use right away is Generics on attributes.

  • @TheOmokage
    @TheOmokage 2 роки тому +1

    Can we now remove [Required] attribute from Fields and replace that to "required member" ?? Do it will work with Json serialisation and ModelState in WebApi ?

  • @salimanahmad5352
    @salimanahmad5352 2 роки тому

    Amazing video has there any other video like C# 1 feature C# 2 feature and so on

  • @limbique
    @limbique 2 роки тому

    Great content. Thank you!

  • @oscareriksson9414
    @oscareriksson9414 2 роки тому

    I like the using spans for strings things. And all the span things. Raw string pretty cool. I guess the interface stuff is pretty cool too.. But couldn't it be done with abstract classes since 20 years or so ago? I mean they need to be implemented by the implementing types still? Am I missing to understan something important? :)

  • @Akumasama
    @Akumasama 2 роки тому

    Omg that INumber interface
    No more switching on the type of input, fuck yes.

  • @JacobSilvia
    @JacobSilvia 2 роки тому

    So excited about generic attributes.

  • @benjaminclehmann
    @benjaminclehmann 2 роки тому

    I'm very interested what happens what happens if you keep a reference to a value passed by the `scoped` keyword past the end of it's lifetime. Does it extend the lifetime by shifting it to the heap? Does it refuse to compile? Does it just let the reference dangle? Is it guaranteed to throw if you attempt to use the dangling reference, or are you just in UB land?

  • @renefuller9241
    @renefuller9241 2 роки тому

    So, List Patterns can be used to search for entire key-values in a hashtable, instead of the Unix regular expressions? As long as you know what pattern you're looking for (which you do since you are writing the code, if you get an unexpected result you throw an exception)

  • @pilotboba
    @pilotboba 2 роки тому

    For sure required fields.
    Pattern matching is nice, but can get a little terse and lower comprehension because you have to "compile" in your head what it's doing.

  • @js6pak
    @js6pak 2 роки тому

    lowered C# viewer in rider is so nice, only JIT asm viewer is left now and sharplab not needed anymore

  • @Michal_Peterka
    @Michal_Peterka 2 роки тому

    List pattern matching is first C# pattern matching where it is nicer way than in F#.

  • @GameRocker
    @GameRocker 2 роки тому +1

    Can you explain more about the "Improved method group conversion to Delegate" and why is a lambda faster than a normal method when the lambda method will be boxed? I thought the opposite was true so I avoided using lambdas anywhere in my code

    • @MrBunt
      @MrBunt 2 роки тому +1

      He has a video on his channel, titled "The C# 11 fix you didn’t know you needed", where he explains it in detail and shows benchmarks and everything

    • @phizc
      @phizc 2 роки тому +2

      Basically, the lambda is cached in a static variable, while the method group recreates a delegate on every invocation.

    • @GameRocker
      @GameRocker 2 роки тому

      @@MrBunt Thanks will look for the video

  • @nomadshiba
    @nomadshiba 2 роки тому

    this sound like microsoft moving features from typescript to c#
    and also taking inspirations from unity dots
    c# is getting better and better
    wish there was version of it that will force you to write optimized code by using new ways of doing things

  • @krzysztofzon8661
    @krzysztofzon8661 2 роки тому

    Generics on attributes ❤

  • @yoanashih761
    @yoanashih761 2 роки тому

    What I like the most is the performance boost in C#11.

  • @christopherhume1631
    @christopherhume1631 2 роки тому

    For me, List Pattern Matching and Generic Math are the most interesting features by far.
    Though Raw String literals are not particularly interesting, this feature will likely see widespread adoption. BTW, I wish the structured @parameter syntax for Serilog played together better with interpolated strings.
    UTF-8 Literals are intriguing; but this feature seems a bit obscure. I am not yet convinced this feature will have much utility.
    What is the reason rollout of Semi-Auto Properties (a.k.a., the field keyword) continues to be delayed? Perhaps some found it objectionable.

  • @Killerspider101
    @Killerspider101 2 роки тому

    Let's hear it for literalliteral strings!!

  • @iGexogen
    @iGexogen 2 роки тому +1

    Very useful video, thanks. But I want to aware unexpirienced developers about first example - coooking xml or json strings by hand is a bad practice. Dont do it in your projects, take it like generic example, not a real case, or you will waste time inventing yet another bicycle (buggy xml/json writer).

    • @nickchapsas
      @nickchapsas  2 роки тому +1

      It is meant to be taken as a generic example, not as a real usecase

    • @qj0n
      @qj0n 2 роки тому +1

      For me, the only place I've put xml or json in code as string were tests. But for that - very handy to place it in tests to test your code with production data. Unit now you either accepted the dirty looking json-in-string, or you put it in separate file to load in test. Now putting it in code is way nicer

    • @iGexogen
      @iGexogen 2 роки тому

      @@nickchapsas I've notived it was a bit closer to real life than other really generic examples. I just wanted to beware anybody who could potentially think you use it in production code.

  • @gronkymug2590
    @gronkymug2590 2 роки тому

    Raw string """xy"xh""" is handy but what one has to do to have " at the end or beginning of the string? :D

  • @virabhadra2
    @virabhadra2 2 роки тому

    It can be a confusion by code reading, when we use a public class based on a file interface, because of need to keep in mind where the class was declared. Looks like it's too flexible, or I'm wrong.

  • @autoeggnet7192
    @autoeggnet7192 2 роки тому

    Is there any mention of performance improvement or benchmark?

  • @pharazfadaei
    @pharazfadaei 2 роки тому

    Does `file` access modifier only apply to types? It will make closed hierarchies and exhaustive switches possible if it can be applied to constructors.

    • @nickchapsas
      @nickchapsas  2 роки тому

      It’s classes, interfaces, structs and delegates

  • @garethandrews3264
    @garethandrews3264 2 роки тому

    Required Required Required ... finally! :D

  • @theMagos
    @theMagos 2 роки тому

    I'm still waiting for extension-everything, and hopefully getting rid of opening up entire namespaces just to use them

  • @Morten746
    @Morten746 2 роки тому

    I remember something about a 'field' keyword or something that could be used to avoid private backing fields. What happened to that?

    • @nickchapsas
      @nickchapsas  2 роки тому

      It was dropped. Maybe we’ll see it in the future

    • @Morten746
      @Morten746 2 роки тому

      @@nickchapsas Man that sucks. I was really looking forward to that. Hopefully it'll be back for the next version.

  • @matthewheys6611
    @matthewheys6611 2 роки тому

    Is this restricted to Net7 or can I use some or all of these in Net6 as well? We are keeping to LTS versions at work.

  • @ashimov1970
    @ashimov1970 Рік тому

    Will List Pattern matching work for object lists/arrays?

  • @FireDragon91245
    @FireDragon91245 2 роки тому

    my vavorit is INumber but what i will use the most is probaply
    """
    this
    """;

  • @VijayNirmal
    @VijayNirmal 2 роки тому

    Create same type of video for older c# versions and have a playlist of it

  • @shaunhunterit342
    @shaunhunterit342 Рік тому

    What IDE is Nick using here?

  • @Ulfius1984
    @Ulfius1984 Рік тому

    How do File Scoped Types work with unit testing?