By tag: foreach
0
kicks
C# Working With ArrayList: What is the best Iterator choice?
When you first look at which statement to use to iterate through an ArrayList collection, the foreach statement stands out. It's syntax is concise and readable as well as no extra lines of code are needed to extract the element you want to work with. But...[pause for effect]...if the collection is...
0
kicks
Lists: Filter, Map and Reduce - and the Magic of IEnumerator.
There are 3 very handy list functions which make dealing with lists a breeze: Map, Filter and Reduce. But along the way of writing them, an important principle of IEnumerator<> comes up.
0
kicks
Why System.Linq.Enumerable doesn't have a ForEach extension method
Lots of people suggest a ForEach method would be a good addition to the base class framework. This is why I don't think it would be, even though our core library has an implementation of it.
0
kicks
JavaScript ForEach Equivalent
One thing with the For Loop in JavaScript is it doesn't seem to be very well documented that you can use it to do an equivalent of a ForEach loop. Here's a short example of doing the ForEach loop equivalent in JavaScript using the "in" keyword.
0
kicks
Create elegant code with Action delegate and List.ForEach method
Small example of how to use Action delegate to perform some action on all elements of a collection.
0
kicks
What's inside a foreach() statement?
A comparision of a foreach() loop and manually looping by calling GetEnumerator() and MoveNext()
0
kicks
Only iterating over the objects you want in a foreach loop
Have you ever had a collection made of several types which all derive from the same base class? How many times have you needed to iterate the whole collection and check each element to make sure its the type that you want to work with? Here's how to do you type checking completely inline inside of...
0
kicks
Performance of foreach vs. List.ForEach
Today I was iterating a List<int> using a foreach-loop and feeling a bit smug in knowing how much more performance-conscious I was being than if I'd tried doing the same thing with an ArrayList filled with ints. Thanks to the wonder of generics, the C# compiler neatly avoids numerous boxing op...