7 awesome improvements for LINQ in .NET 6

แชร์
ฝัง
  • เผยแพร่เมื่อ 4 ม.ค. 2025

ความคิดเห็น • 202

  • @АнтонЧаплыгин-в7х
    @АнтонЧаплыгин-в7х 3 ปีที่แล้ว +58

    MinBy/MaxBy is very-very good alternative to OrderBy(...).First() and here is why:
    There is theorem in algorithmic complexity which states that sorting (OrderBy) of an array of N objects (which can only be compared like IComparable) cannot be done faster than O(N log N), but MinBy/MaxBy can be done very easily in O(N) time. Moreover, OrderBy/sorting operation (in case of IEnumerable, not IQueryable) must load entire collection in memory in order to do the sorting (even if you want just the first element of sorted collection), so it always takes O(N) memory while MinBy/MaxBy requires O(1) memory.

    • @pvjewel
      @pvjewel 3 ปีที่แล้ว

      I think you can solve this problem using Aggregate function which also will give you O(N) complexity. Reference in the video is not quite correct. New names are good though.

    • @АнтонЧаплыгин-в7х
      @АнтонЧаплыгин-в7х 3 ปีที่แล้ว

      @@pvjewel You're right, but it seems to me that people, who doesn't always think about algorithmic complexity of their code, will usually come to the sorting, rather than the aggregate function.

    • @rankarat
      @rankarat 2 ปีที่แล้ว

      MinBy/MaxBy requires O(n) imo;

  • @petrusion2827
    @petrusion2827 3 ปีที่แล้ว +99

    MinBy() and MaxBy() are a great addition, and Take(Range) is also nice

    • @ryanlashkevich9615
      @ryanlashkevich9615 3 ปีที่แล้ว +2

      Yeah, but this new index notation was actually looted from Python. ) Anyway, is a good sign that technologies are being converged - proof of best practice.

    • @briankarcher8338
      @briankarcher8338 3 ปีที่แล้ว +2

      @@ryanlashkevich9615 Agreed. We don't need more language separation. The more they copy form each other (the good stuff at least), the better.

  • @emchammer1815
    @emchammer1815 3 ปีที่แล้ว +1

    Cool videos. I like how quick you are with showing examples. No filler.

  • @Valeriano.A.R
    @Valeriano.A.R 3 ปีที่แล้ว

    For MinBy and MaxBy, we used this naïve implementation:
    public static T MaxBy(this IEnumerable collection, Func func)
    {
    return collection.Aggregate((i1, i2) => func(i1) > func(i2) ? i1 : i2);
    }
    public static T MinBy(this IEnumerable collection, Func func)
    {
    return collection.Aggregate((i1, i2) => func(i1) < func(i2) ? i1 : i2);
    }

  • @foamtoaster9742
    @foamtoaster9742 3 ปีที่แล้ว +3

    This video is so well explained. Even when I didnt grasp the double enumeration call I still felt like the video was relevant to me

  • @jalvrus
    @jalvrus 3 ปีที่แล้ว +23

    I was looking for the batch/chunk operator just last week (in .NET 5). It's nice to see we're getting that. Unfortunately it looks like they still haven't addressed the issue with Min/Max and empty collections. It would be handy to have something like MinOrDefault/MaxOrDefault.

    • @JackMott
      @JackMott 2 ปีที่แล้ว

      you can write your own in 7 minutes

    • @maschyt
      @maschyt 2 ปีที่แล้ว

      You can do list.DefaultIfEmpty().Min() if you want MinOrDefault, the same for MaxOrDefault

  • @olavsalhus
    @olavsalhus 2 ปีที่แล้ว

    Thanks

  • @neralem
    @neralem 3 ปีที่แล้ว +5

    I just want to thank you for the high quality education you give to us. I binch watch your videos and they are perfect in every way. I'm also a C# developer for a living and I've learned a lot by viewing your videos. You made my job much easier. Your knowledge is impressive. Thanks for letting us participate. I'll join your patreon community now.
    Edit: And I've ordered that awesome hoody! :D

  • @steepho9948
    @steepho9948 2 ปีที่แล้ว

    That new way to skip / take is awesome! Reminds me a lot of The Axapta filtering predicates so it just makes sense. Now I want to upgrade to .Net6 :)

  • @lordicemaniac
    @lordicemaniac 3 ปีที่แล้ว +18

    What I would like to see is yield return IEnumerable instead of doing foreach(item in collection) yield return item.

    • @sodiboo
      @sodiboo 3 ปีที่แล้ว

      This wouldn't be compatible with generators of System.Collections.Generic.IEnumerable or System.Collections.IEnumerable, but what about borrowing from Dart with yield* or more in line with "yield return" what about "yield insert" (insert this sequence into my output) or "yield all" (yield all of this sequence's elements) or "yield await" (since yield by itself is invalid afaik so wait until this sequence is done and then continue - not sure how much sense this makes in most contexts, but it's the most natural for Unity Coroutines, but i believe they already support yield enumerable by waiting for that one so shit the one use case already does it better)

    • @dcl525
      @dcl525 3 ปีที่แล้ว +1

      Some cool stuff in the Linq.Async package for handling these scenarios with IAsyncEnumerables.

  • @avinashtauro
    @avinashtauro 2 ปีที่แล้ว

    Very nicely compiled 15 mins of useful features. .NET 6 is really awesome.

  • @mattc4153
    @mattc4153 3 ปีที่แล้ว

    Nice. Thanks for taking the time out

  • @madpanda7954
    @madpanda7954 3 ปีที่แล้ว +3

    The first example is actually very well executed in NumPy (Python library) by the really awesome reshape() method which supports just about any dimension. LINQ can take a note here.

  • @danielas7825
    @danielas7825 2 ปีที่แล้ว

    You have exactly 100.000 followers this very moment. It was so satisfying to my eyes. Haha

  • @benniebees
    @benniebees 3 ปีที่แล้ว +5

    But does ElementAt() try to be smart and see if there is a direct access by index in the underlying data source? Just like Count tries to be smart.

  • @SecondFinale
    @SecondFinale 2 ปีที่แล้ว

    I've been suffixing my IEnumerable variable names with "Query" and it's been great

  • @sherazdotnet
    @sherazdotnet 3 ปีที่แล้ว

    very nice. Loving all these new extension methods

  • @AnthonyFontaine01012014
    @AnthonyFontaine01012014 3 ปีที่แล้ว

    As always awesome content! Really looking forward for the Chunk method!

  • @thefastjojo
    @thefastjojo 3 ปีที่แล้ว +12

    Hope to see some improvements for the EntityFrameworkCore extensions as well

    • @weluvmusicz
      @weluvmusicz 3 ปีที่แล้ว +1

      Are there some new (api) improvements in EF Core 6?

  • @Rolandtheking
    @Rolandtheking 3 ปีที่แล้ว +6

    The chunking part is probably implemented fundamentally different. (i cant find the source code, so i might be off) The example shown enumerates the complete IEnumerable because it uses GroupBy(), the new 'Chunk()' function doesn't enumerate the full IEnumerable before returning the first batch, but only the first chunk.(I think).

    • @nickchapsas
      @nickchapsas  3 ปีที่แล้ว +9

      Yeap the implementation is different. I wanted to show how the top voted stackoverflow solution recommends doing it. We will be doing a round of performance improvements at some point and that will be a talking point

  • @selmanekici315
    @selmanekici315 3 ปีที่แล้ว +1

    That was great video Nick. I like hearing new thing from you.
    I just wanna say you mentioned about index operator when using elementAt() method but the hat operator is different from index operator

    • @johannesalmroth8553
      @johannesalmroth8553 2 ปีที่แล้ว

      Thanks for this comment, was googling this index operator to no avail when hat operator gave me exactly what I needed.

  • @shrikantbmali
    @shrikantbmali 3 ปีที่แล้ว

    As always awesome vid Nick

  • @martinaaron7304
    @martinaaron7304 3 ปีที่แล้ว

    Wow! Thx for sharing. Keep Coding!

  • @keithmasumoto9698
    @keithmasumoto9698 3 ปีที่แล้ว

    Loved this. new sub. Thank you for explaining these!

  • @RobinHood70
    @RobinHood70 3 ปีที่แล้ว +6

    The range syntax has always confused me. In the example with Take(2..4), I would instinctively expect it to take from element 2 through element 4, which is 3 elements. But for whatever reason, Ranges are inclusive of the first element, but exclusive of the last. Anyone know why they did it that way?

    • @mzg147
      @mzg147 3 ปีที่แล้ว

      Basically, we should start numbering from 0 and range 0..n should have n elements. Compare this to the ordinary for loop.

    • @RobinHood70
      @RobinHood70 3 ปีที่แล้ว +1

      @@mzg147 That doesn't make it any better. 0..n should have n+1 elements in my mind. And the ordinary for loop would typically use < .Length or < .Count, both of which are n+1 in an array of 0..n.

    • @sodiboo
      @sodiboo 3 ปีที่แล้ว +5

      Basically because that's usually how it is in most languages i think. They didn't probably wanna overcomplicate it by creating multiple range syntaxes.
      You might enjoy Kotlin and Swift's more clearer syntaxes (in swift, range of 2,3 is 2..

    • @RobinHood70
      @RobinHood70 3 ปีที่แล้ว

      @@sodiboo Interesting. Kotlin and Swift sound more like what I would expect. With differences like these, it's no wonder off-by-one errors are common! lol

    • @mzg147
      @mzg147 3 ปีที่แล้ว

      @@RobinHood70 My comments keep getting deleted lol. I wanted to reference an article by the legendary Djikstra about the topic, but if I write the name of this article the comment will get deleted :( I wrote a lot there!

  • @eugenekim1861
    @eugenekim1861 2 ปีที่แล้ว

    I like C# added the range op that is already supported by PS. Thats very useful.

  • @matrim
    @matrim 3 ปีที่แล้ว +2

    Short version : I can remove a lot of my extensions from my Extensions Library I import on all my projects.
    Only thing I would have liked is that they would implement a ChunkTo as well as a Chunk.
    Where instead of specifying the ChunkSize and I get an X amount of Chunks, I want to specify the ChunkCount and the size of each chunk is the unkown factor

    • @CassioT
      @CassioT 3 ปีที่แล้ว +1

      chunkSize = (int)size/chunkCount

    • @eugenekim1861
      @eugenekim1861 2 ปีที่แล้ว

      More extentions might be good but also getting concerned how well they are optimized.

  • @1944GPW
    @1944GPW 3 ปีที่แล้ว +3

    I recall Pascal having the '..' range / set-of operator thirty five years ago. Nice to see it's now in LINQ.

  • @TheBoxyBear
    @TheBoxyBear 2 ปีที่แล้ว

    Min/Max By is such an obvious addition, when I went to upgrade my project to .NET 6 I actaually got compilation errors because of an ambiguity between the build-in methods and the custom Min/MaxBy I had created.

  • @alekseikharchenko7246
    @alekseikharchenko7246 3 ปีที่แล้ว +1

    I can't understand the idea behind trygetnonenumeratedcount, I mean that it clear what it do, but why do we need it. If we need a count it is needed regardless of whether or not it would require enumerate. We definitely could count and do something else in the same time(e.g. with a foreach loop), but see no reason to maintain that tricky version and have in addition a simpler one for cases where there is a way to get count without enumeration.

    • @nickchapsas
      @nickchapsas  3 ปีที่แล้ว

      The problem is that if you get the count you are also likely to do something with that IEnumerable depending on that count. However if getting the count leads to en enumeration then when you also get the actual values of the enumerable you'll have done the enumeration twice. The option to get whether you can have to count with or without enumeration can help you optimize your approach with that enumeration.

    • @alekseikharchenko7246
      @alekseikharchenko7246 3 ปีที่แล้ว

      @@nickchapsas I mean that in practice if the performance is an issue, and there is the situation when we might need to write down the code to avoid triggering the enumeration then I just don’t see any reason in addition to this code maintain the “if” branch where possible to obtain count without enumeration.
      Also if count makes a sense(i.e. data is finite and code expect to process it all) and for the scenarios where performance matter it might be better to materialise data to array and manipulate with that in “for” loop which would be faster than calling two methods when working with ienumerable.
      So in short I’m just curious which real world code would benefit from this new method.

    • @nickchapsas
      @nickchapsas  3 ปีที่แล้ว

      @@alekseikharchenko7246 I had written this exact code in a share library, before it came in the BCL, because I had tens of usages of it in the past years in multiple projects. The problem is very common, and it's usually seen as "not a problem" because people don't understand enumerables.

    • @alekseikharchenko7246
      @alekseikharchenko7246 3 ปีที่แล้ว

      @@nickchapsas well I still not sure what is the scenario where the method could be used.
      Thanks for the great video anyway, and if one moment I would find a need for this method I’m now aware about its existence :)

  • @kaiserbergin
    @kaiserbergin 3 ปีที่แล้ว +1

    So stoked for 6...

  • @kozhaelf
    @kozhaelf 3 ปีที่แล้ว

    Interesting and concise new syntax

  • @melikechoc0
    @melikechoc0 2 ปีที่แล้ว

    Damn, .NET 6 allowed me to phase out MoreLinq. I still need it for PartialSort, but the good thing about MoreLinq is you can just copy the source code. I hope MoreLinq branches out to more wacky ideas with Linq.

  • @aeonreigh
    @aeonreigh 2 ปีที่แล้ว

    Nice improvements! Wish they have imrovements coming for Except operations.

  • @yukiousuzumi2595
    @yukiousuzumi2595 3 ปีที่แล้ว

    Why can't they fix the double enumeration problem by having a new interface plus overloaded version for all methods on IEnumerable, like Count(out IEnumerated enumerated), and subsequent calls can be made on the enumerated enumerable? In this way it does not only work for Count but any other method, and it's much easier to read than the T22t method

    • @ArtifTh
      @ArtifTh 3 ปีที่แล้ว +1

      IReadOnlyCollection is the such interface

  • @psdmaniac
    @psdmaniac 3 ปีที่แล้ว

    6:08 Why this method is checking the type (implementation). Why it not just call cout() and the way of the implementation depends on concrete type who is implementing IEnumerable. For example list will not iterate and just return the length when Count () is called. No type check is needed. I am confused...

    • @SebGruch
      @SebGruch 3 ปีที่แล้ว +1

      But List does not have Count() method ;-) This is actually IEnumerable extension ;-) In order to read the Count property it must first check the target type is indeed a list...

    • @psdmaniac
      @psdmaniac 3 ปีที่แล้ว

      @@SebGruch Ok.You got right. I though that count() is part of IEnumerable but is not.

  • @guyspentesing5807
    @guyspentesing5807 3 ปีที่แล้ว +1

    *very easy to understand, thank you*

  • @expertreviews1112
    @expertreviews1112 3 ปีที่แล้ว

    Awesome video! Thanks a ton!!!

  • @derekcarr7260
    @derekcarr7260 3 ปีที่แล้ว +2

    The confusing part for me is in RegEx the caret operator (^) means the beginning. The dollar sign ($) means the end.

    • @SJ-uy9vk
      @SJ-uy9vk 3 ปีที่แล้ว +3

      I don’t get why they didn’t use the syntax that python is using, minus sign for counting from the end.

  • @petrmosna2109
    @petrmosna2109 3 ปีที่แล้ว

    Thanks Nick

  • @vincentanzelone8705
    @vincentanzelone8705 3 ปีที่แล้ว

    Fantastic video. Thank you.

  • @antonmartyniuk
    @antonmartyniuk 3 ปีที่แล้ว

    Top video. Keep on coding!

  • @IamSystemko
    @IamSystemko 3 ปีที่แล้ว +1

    Hi Nick! Great video as ever! Could you please examine the volume level in your video?
    It's a lot quieter than needed. Most of the time I watch your video on the subway and it's hard to hear all details due to extraneous noise. I definitely can change the type of headphones that I have but I'm sure there are other people who ask the same.

  • @MrDnbass
    @MrDnbass 3 ปีที่แล้ว

    Great vid, thank bro.

  • @Filipibc1
    @Filipibc1 2 ปีที่แล้ว

    I have not tested with an array of object, but, with an array of int.
    MaxBy is just a little bit faster than OrderByDescending.
    Max is almost 3/4 faster than MaxBy.
    I did a benchmark and got disappointed.
    For loop is the fastest way to find maxValue from an array of int.

  • @simonfarre4907
    @simonfarre4907 3 ปีที่แล้ว +1

    The max by and min by also doesn't sort, no? When you did the orderBy and then first, don't you first do a sorting which means you could potentially iterate and do N + M swaps? Shouldn't maxBy be a lot, lot, lot more efficient by just iterating over the N elements and return the element where the predicate is true for?
    Or maybe the orderBy just internally creates a list of indices containing the index list of progression when iterating? In either way, it requires additional memory that maxBy shouldn't for instance. But I am not a C# developer

  • @CRBarchager
    @CRBarchager 3 ปีที่แล้ว

    Thank you for the video!

  • @ivanm07
    @ivanm07 2 ปีที่แล้ว

    Good features to add in my code

  • @pieceofcode_
    @pieceofcode_ 2 ปีที่แล้ว

    Can someone please help me on Linq filters
    I have list of products say lstProducts
    And based on conditions from database I wanted to sort this list dynamically, how can I achieve that.
    Product has id, name, price, season
    Sorting object has: sortid, sort name
    If sortname = season
    {
    data = lstProduct.where(c=>c.season==“winter”).ToList():
    If(sort.price==1)
    Sort data variable high to low
    Else
    Low to high
    }
    So like this there are multiple conditions but every time I have to pick bunch of records from main list and sort that bunch and add to new list variable
    I think this is not a good way, can you pls suggest

  • @heyho4414
    @heyho4414 3 ปีที่แล้ว +1

    Please make video that explaining IEnumerable!

  • @moc2130
    @moc2130 3 ปีที่แล้ว

    Thanks Nick, that was good.

  • @davidshukvani
    @davidshukvani 3 ปีที่แล้ว

    Thank you for the video, It was very interesting. Could you add the previews of how those linq sratements get translated in SQL? I mean no need to adjust current video, I will also check it out myself, but just to fill in, it might be interesting to see how EF translates those starements. Other than that, it was very good, thank you! Keep up the good work

  • @shioli3927
    @shioli3927 3 ปีที่แล้ว +1

    I wonder about the MinBy MaxBy if OrderBy and First is really that good of an idea pre .net 6. Maybe linq has some magical optimization somewhere that I don´t know about. But I would think that ordering can be potentially really god damn slow if you just want the maximum. So I´ve mostly used something like Aggregate((x, y) => x > y ? x : y) or you know loops ain´t forbidden techniques just because linq exists. Nice addition I guess. Its just one of those things that always tripped me up a bit that everyone seems to do. And i get that sometimes this is no big deal. Like if it´s a database query generally I don´t worry about it, because probably the orderby is indexed (hopefully) and it becomes some kind of query language. It won´t have to order, it just has to get an index from one end. But that isn´t true for some sizeable in memory list. You actually have to iterate probably significantly more than 1 time to get an ordered enumeration out of some in memory anything.

    • @АнтонЧаплыгин-в7х
      @АнтонЧаплыгин-в7х 3 ปีที่แล้ว

      There is theorem in algorithmic complexity which states that sorting (OrderBy) of an array of N objects (which can only be compared like IComparable) cannot be done faster than O(N log N), but MinBy/MaxBy can be done very easily in O(N) time. Moreover, OrderBy/sorting operation (in case of IEnumerable, not IQueryable) must load entire collection in memory in order to do the sorting (even if you want just the first element of sorted collection), so it always takes O(N) memory while MinBy/MaxBy requires O(1) memory.

  • @adabsurdum7011
    @adabsurdum7011 3 ปีที่แล้ว

    Nice one, thanks

  • @felvinperez957
    @felvinperez957 3 ปีที่แล้ว

    HI! what about the where expression with multiple condition and or. Is it implemented already?? I mean im having multiple conditions using and or empty condition.. Instead of writing a multiple and condition if it is present i will wite it in a single where expression...

  • @HugRunner
    @HugRunner 3 ปีที่แล้ว +4

    Some really nice improvements. I guess MS is somewhat consistent, but I wish they would do ranges differently, just like new Random().Next(1,100) is probably read by most that you would get a number from 1 to 100 (incl. 100) but actually it's 1 to 99 only. Same with the Take(range) now; you wrote (2..4) and you got index 2 and 3, but not 4. It's quite confusing in my opinion and easy to misunderstand when writing or reading code quickly.

  • @stefanbogdanovic590
    @stefanbogdanovic590 3 ปีที่แล้ว +6

    12:03 It would be pain in the, where you don't wanna have pain hahahahaha 🤣

  • @11r3start11
    @11r3start11 3 ปีที่แล้ว

    Hi Nick, I'm wondering about your opinion about "MinBy" and stuff... We already have Count(x => ..) without By, and having this "By" breaks overloading concepts... Why do you think it was don't this way?

  • @chimaokoli4943
    @chimaokoli4943 3 ปีที่แล้ว

    My regards to Peter and Maria. Tell the I enjoy your videos.

  • @gregcyrus2739
    @gregcyrus2739 3 ปีที่แล้ว

    .skip().take() was great - but .take(range) is awesome 👍🏼

  • @jonah8650
    @jonah8650 3 ปีที่แล้ว

    Great video

  • @rowllenscunanan3096
    @rowllenscunanan3096 3 ปีที่แล้ว

    what is your IDE was using?

  • @hassansiddique2936
    @hassansiddique2936 3 ปีที่แล้ว

    how you go to the framework non compiled code ?

  • @dimalisovyk5277
    @dimalisovyk5277 3 ปีที่แล้ว +2

    I Implemented those MinBy, MaxBy, DistinctBy so many times...

  • @majorjohnson8001
    @majorjohnson8001 2 ปีที่แล้ว

    Hnnng, index operators. Probably the one thing I liked about Python.

  • @jimread2354
    @jimread2354 2 ปีที่แล้ว

    The zip expansion and the *By functions seem like summer intern projects 😏

  • @ahmedrazzak5141
    @ahmedrazzak5141 3 ปีที่แล้ว

    Awesome as aways👍🏻

  • @younglynk
    @younglynk 3 ปีที่แล้ว +3

    Hey Nick, great video!
    Quick question. How do you make your debugging window (when hovering over variables) in Rider autosize when opening different statements? Mine is fixed size and it's really annoying. It's something new in the early access program? thanks!

  • @thanasakis61
    @thanasakis61 3 ปีที่แล้ว

    Ωραίος αδερφέ!

  • @digitalman2112
    @digitalman2112 3 ปีที่แล้ว

    I really got into Python several years ago and glad to see a lot of features making their way to C#.

  • @acomment8595
    @acomment8595 3 ปีที่แล้ว

    Does MinBy and MaxBy use First() or FirstOrDefault()?

  • @caubehinhbong
    @caubehinhbong 3 ปีที่แล้ว

    Have PWDCOMPARE in LinQ?

  • @Vastlee
    @Vastlee 3 ปีที่แล้ว +2

    Is the Zip enhancement simply a 2 to 3, or is it 2 to however many want?

    • @nickchapsas
      @nickchapsas  3 ปีที่แล้ว +2

      no they just added the overload for 3

    • @Vastlee
      @Vastlee 3 ปีที่แล้ว

      @@nickchapsas Thanks! 🤔 I'm sure there's a good reason for limiting it. ¯\_(ツ)_/¯

    • @protox4
      @protox4 3 ปีที่แล้ว

      You can always extend to however many you want yourself, by repeatedly calling Zip and collapsing the resulting tuple. Though that's probably less performant than doing it manually...

  • @anderslinden4701
    @anderslinden4701 3 ปีที่แล้ว

    Why not allow names.ElementAt(-3)?

  • @flamingliu1858
    @flamingliu1858 3 ปีที่แล้ว

    Index range is awesome!

  • @sahawndada
    @sahawndada 3 ปีที่แล้ว

    Great vid btway

  • @andrewmorton9683
    @andrewmorton9683 3 ปีที่แล้ว

    Would Secretlab make you a chair with the logo stitching mirrored?

    • @nickchapsas
      @nickchapsas  3 ปีที่แล้ว

      I’ve gotta tell you. It triggers me every single time I edit a video

    • @andrewmorton9683
      @andrewmorton9683 3 ปีที่แล้ว

      @@nickchapsas Lol. Chair back doilies are a thing ;)

  • @IamDraaky
    @IamDraaky 3 ปีที่แล้ว

    So they used MoreLinq's Batch functionality for Chunk, nice.

  • @fullduckdev7327
    @fullduckdev7327 3 ปีที่แล้ว

    Re: Chunking - I think there was a Batch() method in moreLINQ for that. Obvs better to have those functionalities within LINQ natively

  • @oOserkanCakmakOo
    @oOserkanCakmakOo 3 ปีที่แล้ว

    Thank you very much

  • @peterjosefsson9857
    @peterjosefsson9857 2 ปีที่แล้ว

    So how do these look like in actual linq, as in language-integrated query? Are they implemented there, or do they only exist in the support library (a.k.a. fluent linq) we use because we're too lazy to learn actual linq? 🤣
    Also, what does EF Core do with them? Anything? Or does it just give up on them?

  • @arghasen6535
    @arghasen6535 2 ปีที่แล้ว

    Zip function is also present in python

  • @phekomoroke2148
    @phekomoroke2148 3 ปีที่แล้ว

    Which program did you use to record the tutorial?

  • @mark7166
    @mark7166 3 ปีที่แล้ว

    What IDE are you using? It looks like Visual Studio, but different.

    • @nickchapsas
      @nickchapsas  3 ปีที่แล้ว

      It's called JetBrains Rider

    • @mark7166
      @mark7166 3 ปีที่แล้ว

      @@nickchapsas Cool, thanks man!

  • @Н.Игорь
    @Н.Игорь 3 ปีที่แล้ว

    Are there anything as convenient as python slices in C#? I thought that "^3" is not as intuitive as "-3". It seems that the expression was taken from regex, where start($) and end(^) looks like that.

    • @sodiboo
      @sodiboo 3 ปีที่แล้ว

      regex uses ^ on the start and $ at the end - i think the main reason is backwards compatibility, python always used negative indices so it's no problem but in C# negative numbers could already have a purpose, and some consumers may rely on an exception when they reach negatives (which then results in looping the whole collection again until it goes out of bounds from end, changing the behaviour and not only preventing it from running, which is VERY BAD), so the only solution is a new type called Index, and although it's not immediately clear what ^3 means, i don't think it will be much of an issue in cases like MyArr[0..^3] which is the most common one, and it doesn't really look like anything else (unary XOR?) so it's fine and doesn't break old code

    • @petrusion2827
      @petrusion2827 3 ปีที่แล้ว +1

      All a matter of perspective. ^3 seems much more intuitive to me than -3.

    • @gallergur
      @gallergur 3 ปีที่แล้ว

      How is it more intuitive? Moving to the end of the collection when indexes go below 0 is exactly like starting again from the beginning when you reach the end of a collection (i.e. index n+1 is same as index 1). Overflows already mean something (non-existent indexes)...just let them be that. The new operator is another concept to learn, but at least it does not conflict with our current mental model of indexes (and as mentioned above, also the model that existing code uses, that may check for negative indexes as a sign of overflow)

    • @sodiboo
      @sodiboo 3 ปีที่แล้ว

      @@petrusion2827 To me they're both the same (index 3 with a special modifier meaning from end), and because -3 is already invalid for arrays (index out of bounds) it's very obvious why they instead chose a new ^3 syntax

    • @recursiv
      @recursiv 3 ปีที่แล้ว

      [..^0] means take everything. [..-0] means take nothing.

  • @GothicMods
    @GothicMods 3 ปีที่แล้ว +1

    Your "old-way example" of getting youngest family member by writing family.OrderBy(x => x.Age).First() is also very bad considering performance. Sorting everything take O(n*log(n)) time, but is easily duable without it in a linear time...

    • @nickchapsas
      @nickchapsas  3 ปีที่แล้ว +4

      It's not my way. It's the most voted way in stackoverflow. It's there to demonstrate how people googling the problem will most likely deal with it. I should have mentioned that in the video.

    • @sodiboo
      @sodiboo 3 ปีที่แล้ว

      well it is using LINQ, the fastest would be to loop over and get the minimum like that, or for roughly equivalent i guess reduce my min count and element in a tuple?

  • @hom-sha-bom
    @hom-sha-bom 3 ปีที่แล้ว

    I do not understand the take 2 to 4 syntax at all. "2..4", to mean that would mean index 2, 3, and 4. Why does it return only 3 and 4?

    • @recursiv
      @recursiv 3 ปีที่แล้ว

      It gives 2 and 3. It's the same as for(i=2; i

  • @kirillsviderski4739
    @kirillsviderski4739 3 ปีที่แล้ว

    Great things are introduced

  • @devildude5842
    @devildude5842 3 ปีที่แล้ว

    How are you able to get external code ? Are you using some nuget package or anything else. It's really insightful.

    • @briankarcher8338
      @briankarcher8338 3 ปีที่แล้ว

      Are you referring to the .NET Internal Code? Microsoft allows access to their symbol repository.

  • @Guiltfeeder566
    @Guiltfeeder566 3 ปีที่แล้ว

    Very nice! What IDE is that?

    • @nickchapsas
      @nickchapsas  3 ปีที่แล้ว

      It’s JetBrains Rider

  • @viktordoe1636
    @viktordoe1636 3 ปีที่แล้ว

    Noob question: how do you get the IL code?

  • @Andreas-gh6is
    @Andreas-gh6is 3 ปีที่แล้ว

    "Quality of Life" and C#. Good one...

    • @thomas5540
      @thomas5540 3 ปีที่แล้ว

      who shat in your cereal?

  • @MrBraZze4R
    @MrBraZze4R 3 ปีที่แล้ว

    Can u help me to know what should learn to become a .Net developer

  • @jcm95
    @jcm95 3 ปีที่แล้ว

    It looks like a lot of influence from Python and Pandas! .NET moving towards data science?

  • @danielabreugonzalez9385
    @danielabreugonzalez9385 3 ปีที่แล้ว

    which one is that IDE ?

  • @wasabi_san
    @wasabi_san 2 ปีที่แล้ว

    To avoid multiple enumeration just do a .ToList()

    • @nickchapsas
      @nickchapsas  2 ปีที่แล้ว

      The point is that even that enumeration of ToList can be prevented. That’s the exact problem we are trying to solve

    • @wasabi_san
      @wasabi_san 2 ปีที่แล้ว

      @@nickchapsas `TryGetNonEnumeratedCount` will just yield 0 in most practical usages of IEnumerable, such as when querying a database or other external data sources like APIs (I tend to use IQueryable but I am not going to get into that). In these cases, it is not possible to know the count of something that you have never counted {enumerated}. Keep in mind that if my application needs the count of a collection then I need it regardless if TryGetNonEnumeratedCount succeeds or not. This sounds like an interesting feature but what are some practical examples of this?

  • @captkalik
    @captkalik 2 ปีที่แล้ว

    For the Take example couldn’t you just do names[2..4]

    • @captkalik
      @captkalik 2 ปีที่แล้ว

      Actually nvm, the Take version returns IEnumerable while just doing names[2..4] returns string[], so I guess it depends on what the dev wants to have returned

  • @mlpalphapony491
    @mlpalphapony491 3 ปีที่แล้ว

    C# lang devs in 2021: We'll create ZIP method! :0

  • @mhmohammadi9652
    @mhmohammadi9652 2 ปีที่แล้ว

    awsome

  • @jasonhunter6125
    @jasonhunter6125 3 ปีที่แล้ว

    I wonder why absolutely all coding channels are on so big screens. None are made to watch on a phone. Anyone know of any?

    • @nickchapsas
      @nickchapsas  3 ปีที่แล้ว

      Did you try full screen on your phone?

    • @jasonhunter6125
      @jasonhunter6125 3 ปีที่แล้ว

      @@nickchapsas i have a big note 10. This video is not meant to be viewed on a mobile