Great job. The reason for implementing two GetEnumerator() method one returning IEnumerator (prtty much IEnumerator ) and another IEnumerator is backward compatibility with Net 1.0 which did not support generics
Whole idea of LINQ Extensions methods works for classes which implements IEnumerable interface, so it is interesting to see how actually that iteration inside it works. Nice video, keep up the good work!
what is this Dump() method? is it part of LINQ? I can't seem to find anything about it anywhere and Rider throws a "can't resolve symbol" error when trying to use it despite importing the LINQ library. Also, the IEnumerable declaration also throws an error on the type, saying that IEnumerable doesn't have type parameters. Thanks for any help.
@@RawCoding damn okay haha. I see pretty much every reply is you clarifying you're using LinqPad so I feel kind of bad that you're endlessly repeating yourself. Just not familiar with LinqPad so didn't know. Thanks.
it depends on what you need. if you return IEnumerable without using the yield keyword no generator will be created. to put it simply IEnumerable represents something that create multiple values, be it they are already there on not there. If you need a collection of a known size use a list
Thank you, Anton. Recently, I have found that IList.Insert(0, element) was 10 ~ 30 times faster than IList.Add(element)? Does it relate to yield return?
Don’t think so, yield return turns the function in to a generator you can’t add or insert in to a generator. For lists it depends how you tested it and what the implementation you’ve used.
@@RawCodingno special implementation. Just stored int numbers representing all cases of nCr , for example, 30C12. Actually, I prefer Array because I believe it consumes less memory. So, at first, I used arrays to store those cases but changed it into List which looks neater. At the time, I found IList.Add() is slightly faster than Array assignment. Later, I had to change the order where cases are stored so simply replaced IList.Add() with IList.Insert(0, x). then, I found IList.Insert(0, x) is much much faster than IList.Add(). For example, when producing all the cases of 13C5, array takes around 0.22 seconds, IList.Add does it 0.03 seconds faster but IList.Insert does it in 0.007 seconds on my AMD Ryzen 7 2700U 2.20 GHz laptop. I used StopWatch instances to check the time. of course, those times changes at every execution but the speed difference always is apparent.
List can have an implementation of a linked list or array list or immutable list - pint is there are many lists - insert at index means you say where to insert, without index the app has to perform an operation to find out, in a linked list it would have to iterate all the elements to append the element on the end.
Golden RUclipsr. I only had to skip around in your videos to find what I needed - but damn. You go through everything so detailed. Big Thanks!
Thank you for watching ))
Great job. The reason for implementing two GetEnumerator() method one returning IEnumerator (prtty much IEnumerator ) and another IEnumerator is backward compatibility with Net 1.0 which did not support generics
Aha cheers )
Whole idea of LINQ Extensions methods works for classes which implements IEnumerable interface, so it is interesting to see how actually that iteration inside it works. Nice video, keep up the good work!
Thank you for watching))
Another great video here. You are on a roll with great content. Your delivery is spot -on and engaging.
thank you :)
Thank you for your videos, very informative and clear explanation.
Cheers :) glad you like them
And as always your explanation is the best:)
Cheers man )
what is this Dump() method? is it part of LINQ? I can't seem to find anything about it anywhere and Rider throws a "can't resolve symbol" error when trying to use it despite importing the LINQ library. Also, the IEnumerable declaration also throws an error on the type, saying that IEnumerable doesn't have type parameters. Thanks for any help.
It’s a LinqPad thing, LinqPad is the scripting tool I’m using
@@RawCoding damn okay haha. I see pretty much every reply is you clarifying you're using LinqPad so I feel kind of bad that you're endlessly repeating yourself. Just not familiar with LinqPad so didn't know. Thanks.
Hi, should i return from a method the IEnumerable interface or the concrete type? Thanks in advance.
it depends on what you need. if you return IEnumerable without using the yield keyword no generator will be created. to put it simply IEnumerable represents something that create multiple values, be it they are already there on not there. If you need a collection of a known size use a list
@@RawCoding Thanks for response, if I need to return database rows?
Tell me what do you think? Hint “I don’t know” is not a good answer
@@RawCoding Return values from database is considered a known number of object, right? So I can return a list?
Thank you, Anton.
Recently, I have found that IList.Insert(0, element) was 10 ~ 30 times faster than IList.Add(element)?
Does it relate to yield return?
Don’t think so, yield return turns the function in to a generator you can’t add or insert in to a generator. For lists it depends how you tested it and what the implementation you’ve used.
@@RawCodingno special implementation. Just stored int numbers representing all cases of nCr , for example, 30C12.
Actually, I prefer Array because I believe it consumes less memory.
So, at first, I used arrays to store those cases but changed it into List which looks neater.
At the time, I found IList.Add() is slightly faster than Array assignment.
Later, I had to change the order where cases are stored so simply replaced IList.Add() with IList.Insert(0, x).
then, I found IList.Insert(0, x) is much much faster than IList.Add().
For example, when producing all the cases of 13C5, array takes around 0.22 seconds, IList.Add does it 0.03 seconds faster but IList.Insert does it in 0.007 seconds on my AMD Ryzen 7 2700U 2.20 GHz laptop.
I used StopWatch instances to check the time. of course, those times changes at every execution but the speed difference always is apparent.
List can have an implementation of a linked list or array list or immutable list - pint is there are many lists - insert at index means you say where to insert, without index the app has to perform an operation to find out, in a linked list it would have to iterate all the elements to append the element on the end.
@@RawCoding Many thanks, Anton. Then, it is true that IList.Insert has good benefit when the storing order doesn't matter.
Yes
Awesome content. Best I've found.
Thank you
What IDE are you using?
Rider and LinqPad
Maybe a dumb question but what are you programming in and why not visual studio?
Great explanation of ienumerable btw
It’s called LinqPad and it’s just way faster to run the program and easier to visualise
Man U are The Best Keep it Up :)
It’s Up!
Not very well explained. Your example used in the first 7mins was confusing. Your examples are usually easier to follow.
Woudl you be able to explain why it's confusing?