Top "Foreach" questions

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

In C#, why can't I modify the member of a value type instance in a foreach loop?

I know that value types should be immutable, but that's just a suggestion, not a rule, right? So why can't …

c# foreach immutability value-type
Error in datarow,Collection was modified; enumeration operation might not execute

I have for-each loop in which the data row is updated so the exception ,Collection was modified; enumeration operation might …

c# foreach datarow
what use does the javascript forEach method have (that map can't do)?

The only difference I see in map and foreach is that map is returning an array and forEach is not. …

javascript arrays dictionary foreach prototype
"Nested foreach" vs "lambda/linq query" performance(LINQ-to-Objects)

In performance point of view what should you use "Nested foreach's" or "lambda/linq queries"?

c# lambda foreach linq-to-objects
Exception java.util.LinkedHashMap cannot be cast to java.util.List

While working around following code I got the exception given below. List<Map<String, Object>> obj = …

java foreach mapper
The invocation context (this) of the forEach function call

I was wondering what the 'this' value (or invocation context) is of the forEach callback function. This code doesn't seem …

javascript function foreach this invocation
What is the most efficient loop in c#

There are a number of different way to accomplish the same simple loop though the items of an object in …

c# loops for-loop foreach while-loop
How to check if a variable is an IEnumerable of some sort

basically I'm building a very generic T4 template and one of the things I need it to do is say …

c# generics foreach ienumerable
Extract lines matching a pattern from all text files in a folder to a single output file

I am trying to extract each line starting with "%%" in all files in a folder and then copy those lines …

powershell foreach filtering get-childitem select-string
ForEach() : Why can't use break/continue inside

Since ForEach() method loop through all a list members, Why cant use a break/continue clause while i can use …

c# foreach break continue