tagged [foreach]
Are Parallel.Invoke and Parallel.ForEach essentially the same thing?
Are Parallel.Invoke and Parallel.ForEach essentially the same thing? And by "same thing" I mean do these two operations basically do the same work, and it just boils down to which one is more convenie...
- Modified
- 19 Jan at 00:2
How to implement for-else and foreach-else in C# similar to Python's for-else and while-else?
How to implement for-else and foreach-else in C# similar to Python's for-else and while-else? Python's and loops include an optional clause which execute if the loop exits normally ( without a stateme...
- Modified
- 7 Nov at 17:30
Lambda Expression using Foreach Clause
Lambda Expression using Foreach Clause > [Why is there not a ForEach extension method on the IEnumerable interface?](https://stackoverflow.com/questions/101265/why-is-there-not-a-foreach-extension-met...
Parallel.ForEach loop with BlockingCollection.GetConsumableEnumerable
Parallel.ForEach loop with BlockingCollection.GetConsumableEnumerable Why `Parallel.ForEach` loop exits with `OperationCancelledException`, while using `GetConsumableEnumerable`? ``` //outside the fun...
- Modified
- 2 Jun at 11:2
how do I check if an entity is the first element of a foreach loop
how do I check if an entity is the first element of a foreach loop Say I have a `foreach` loop. I have to do something with the first object of the loop that I don't have to do with any of the other o...
Performance difference for control structures 'for' and 'foreach' in C#
Performance difference for control structures 'for' and 'foreach' in C# Which code snippet will give better performance? The below code segments were written in C#. 1. ``` for(int tempCount=0;tempCoun...
- Modified
- 20 Jan at 23:8
Changing objects value in foreach loop?
Changing objects value in foreach loop? In one place i am using the list of string in that case the i am able to change the value of the string as code given below, But for object of class i am not ab...
- Modified
- 30 Dec at 12:54
JSON forEach get Key and Value
JSON forEach get Key and Value I have the following `forEach` loop over a JSON object called `obj`: How can I make it `console.log` both `key` and `value` of each item inside the object? Something lik...
- Modified
- 3 Dec at 15:18
change values in array when doing foreach
change values in array when doing foreach example: The array is still with it's original values, is there any way to have writing access to array's elements from iterating function ?
- Modified
- 26 Nov at 12:58
Short circuit Array.forEach like calling break
Short circuit Array.forEach like calling break How can I do this using the new `forEach` method in JavaScript? I've tried `return;`, `return false;` and `break`. `break` crashes and `return` does noth...
- Modified
- 28 Oct at 09:21
How to 'foreach' a column in a DataTable using C#?
How to 'foreach' a column in a DataTable using C#? How do I loop through each column in a datarow using `foreach`?
Loop through all the rows of a temp table and call a stored procedure for each row
Loop through all the rows of a temp table and call a stored procedure for each row I have declared a temp table to hold all the required values as follows: ``` DECLARE @temp TABLE ( Password INT, ...
- Modified
- 1 Sep at 12:10
break out of if and foreach
break out of if and foreach I have a foreach loop and an if statement. If a match is found i need to ultimately break out of the foreach.
- Modified
- 13 Jul at 14:34
Iterate over elements of List and Map using JSTL <c:forEach> tag
Iterate over elements of List and Map using JSTL tag If I have a JSF backing bean return an object of type ArrayList, I should be able to use `` to iterate over the elements in the list. Each element ...
"Avoid allocations in compiler hot paths" Roslyn Coding Conventions
"Avoid allocations in compiler hot paths" Roslyn Coding Conventions I've been reading through the [Contributing Code](https://roslyn.codeplex.com/wikipage?title=How%20to%20Contribute&referringTitle=Ho...
- Modified
- 20 Jun at 09:12
Is there a foreach construct in TypeScript similar to the C# implementation?
Is there a foreach construct in TypeScript similar to the C# implementation? I really like using the `foreach` construct for "for loops" in C#. I think it's very clean, efficient and readable. Is the...
- Modified
- 19 Apr at 11:43
How do I exit a foreach loop in C#?
How do I exit a foreach loop in C#? Whenever violated is true, I want to get o
How to get values of selected items in CheckBoxList with foreach in ASP.NET C#?
How to get values of selected items in CheckBoxList with foreach in ASP.NET C#? I have a CheckBoxList like this: ``` TG Gold Silver NE
- Modified
- 19 Feb at 21:9
Linq style "For Each"
Linq style "For Each" Is there any Linq style syntax for "For each" operations? For instance, add values based on one collection to another, already existing one: Instead of
Declare variable in Razor
Declare variable in Razor I want to add a variable outside the foreach and then use that inside the foreach loop ``` Date Location @int i; @foreach (var item in Model) { i=0; ...
- Modified
- 18 Dec at 09:44
Getting "The connection does not support MultipleActiveResultSets" in a ForEach with async-await
Getting "The connection does not support MultipleActiveResultSets" in a ForEach with async-await I have the following code using Dapper.SimpleCRUD : ``` var test = new FallEnvironmentalCondition[] { ...
- Modified
- 3 Dec at 10:11
Difference between "as $key => $value" and "as $value" in PHP foreach
Difference between "as $key => $value" and "as $value" in PHP foreach I have a database call and I'm trying to figure out what the `$key => $value` does in a `foreach` loop. The reason I ask is becaus...
Does foreach() iterate by reference?
Does foreach() iterate by reference? Consider this: Is `obj` a reference to the corresponding object within the list so that when I change the property the change will persist in the object instance o...
Go to "next" iteration in JavaScript forEach loop
Go to "next" iteration in JavaScript forEach loop How do I go to the next iteration of a JavaScript `Array.forEach()` loop? For example: [MDN docs](https://developer.mozilla.org/en-US/docs/Web/JavaScr...
- Modified
- 11 Aug at 22:45