Top "Foreach" questions

foreach is a looping construct that executes a given piece of code for each element in a list/collection/array.

Is a LINQ statement faster than a 'foreach' loop?

I am writing a Mesh Rendering manager and thought it would be a good idea to group all of the …

c# performance linq foreach
Counter in foreach loop in C#

Working of foreach: As I know, foreach is a loop which iterates through a collection or array one by one, …

c# foreach counter
Is there a way to iterate over a dictionary?

I know NSDictionaries as something where you need a key in order to get a value. But how can I …

ios objective-c foreach iteration nsdictionary
PHP create key => value pairs within a foreach

I want to create a key-value pairs in an array within a foreach. Here is what I have so far: …

php arrays foreach key-value
PHP PDO with foreach and fetch

The following code: <?php try { $dbh = new PDO("mysql:host=$hostname;dbname=$dbname", $username, $password); echo "Connection is successful!&…

php mysql pdo foreach fetch
Advantages of std::for_each over for loop

Are there any advantages of std::for_each over for loop? To me, std::for_each only seems to hinder …

c++ stl foreach coding-style
batch script - run command on each file in directory

I need to convert some xls files into xlsx files. I can successfully convert one xls file into xlsx by …

batch-file cmd foreach ssconvert
Automatically get loop index in foreach loop in Perl

If I have the following array in Perl: @x = qw(a b c); and I iterate over it with foreach, …

perl foreach
Iterate Multi-Dimensional Array with Nested Foreach Statement

I think this might be a pretty simple question, but I haven't been able to figure it out yet. If …

c# foreach nested-loops
Performance of FOR vs FOREACH in PHP

First of all, I understand in 90% of applications the performance difference is completely irrelevant, but I just need to know …

php arrays performance foreach for-loop