tagged [foreach]
Check if object value exists within a Javascript array of objects and if not add a new object to array
Check if object value exists within a Javascript array of objects and if not add a new object to array If I have the following array of objects: Is there a way to loop through the array to check wheth...
- Modified
- 3 Apr at 17:15
Max Degree of Parallelism for AsParallel()
Max Degree of Parallelism for AsParallel() While using `Parallel.ForEach` we have the option to define the Parallel options and set the Max Degree of Parallelism like : But while doing PLINQ like: I w...
- Modified
- 3 May at 11:51
For..In loops in JavaScript - key value pairs
For..In loops in JavaScript - key value pairs I was wondering if there's a way to do something like a PHP `foreach` loop in JavaScript. The functionality I'm looking for is something like this PHP Sni...
- Modified
- 22 Feb at 13:29
Check for null in foreach loop
Check for null in foreach loop Is there a nicer way of doing the following: I need a check for null to happen on file.Headers before proceeding with the loop In short it looks a bit ugly to write the...
Why can't I do foreach (var Item in DataTable.Rows)?
Why can't I do foreach (var Item in DataTable.Rows)? Is there a reason why I can't do the following: rather than having to do I would have thought this was possible, like it is on other datatypes. For...
Counter in foreach loop in C#
Counter in foreach loop in C# As I know, > So, if I have n items in an array. then, In, 1st iteration, then, in 2nd, . . . in last (nth), from working it seems that at each iteration it knows that...
Why can't we assign a foreach iteration variable, whereas we can completely modify it with an accessor?
Why can't we assign a foreach iteration variable, whereas we can completely modify it with an accessor? I was just curious about this: the following code will not compile, because we cannot modify a f...
Break parallel.foreach?
Break parallel.foreach? [parallel.for](http://msdn.microsoft.com/en-us/library/system.threading.tasks.parallel.for.aspx) I have a pretty complex statement which looks like the following: ``` Parallel....
- Modified
- 3 Dec at 19:47
Why is the C# compiler happy with double IEnumerable<T> and foreach T?
Why is the C# compiler happy with double IEnumerable and foreach T? I know this code does not work (and have no problems writing it in a way that will work). I was wondering how the compiler can build...
- Modified
- 25 Nov at 22:41
System.Timers.Timer massively inaccurate
System.Timers.Timer massively inaccurate I've written a program which uses all available cores by using `Parallel.ForEach`. The list for the `ForEach` contains ~1000 objects and the computation for ea...
- Modified
- 18 Sep at 19:46
Error in datarow,Collection was modified; enumeration operation might not execute
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 , is generated. any way to fix it? i have seen ...
How to skip a specific position within a for each loop in c sharp?
How to skip a specific position within a for each loop in c sharp? ``` List liste = new List { "A","B","C","D" }; foreach (var item in liste) { System.Diagnostics.Debug.Wri...
Skip items of a specific type in foreach loop
Skip items of a specific type in foreach loop I have this code for filling datatable from excel file: I h
Are there any side effects of returning from inside a foreach statement?
Are there any side effects of returning from inside a foreach statement? Similar to my question about [returning from inside a using statement](https://stackoverflow.com/questions/2369887/are-there-an...
Restart a foreach loop in C#?
Restart a foreach loop in C#? How can I restart a `foreach` loop in C#?? For example: `restart` here is like `continue` or `break` but it restarts the foreach from the begining It is like setting the ...
- Modified
- 22 Aug at 06:20
Does foreach automatically call Dispose?
Does foreach automatically call Dispose? In C#, Does foreach automatically call Dispose on any object implementing IDisposable? [http://msdn.microsoft.com/en-us/library/aa664754(v=vs.71).aspx](http://...
- Modified
- 13 Feb at 04:23
C#, Looping through dataset and show each record from a dataset column
C#, Looping through dataset and show each record from a dataset column In C#, I'm trying to loop through my dataset to show data from each row from a specific column. I want the get each date under th...
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
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
Parallel.ForEach and async-await
Parallel.ForEach and async-await I had such method: Then I decided to use `Parallel.ForEach`: ``` pub
- Modified
- 21 May at 06:50
Why does List<T>.ForEach() implement a for loop?
Why does List.ForEach() implement a for loop? I don't understand why the `List.ForEach()` extension method implements a `for` loop under the hood. This opens up the possibility of the collection being...
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...
laravel foreach loop in controller
laravel foreach loop in controller i have a problem about looping data in controller (laravel 4). my code is like this: when i want to use foreach to loop for $product result with code like this: ``` ...