» Home » Foreach » Page 1
foreach within a foreach in wordpress is getting the values from the first foreach
by Julian Ivanov in Development Tools & Services

Sorry for the confusing title. I am displaying a list of posts in wordpress and using a foreach to display an image,title etc from each post. What I then need is for each post to have a navigation which provides links to the other posts within the same page using anchors.


I have created another foreach within the first one which grabs the same posts again and generates a navigation


How Use Parallel.ForEach Loop Instead Of Regular Foreach? (Info About Parallel.ForEach)
by Ben in Programming Languages

I am a bit of confused about Parallel.ForEach.
what is Parallel.ForEach and what does exactly do?
please don't reference any MSDN link.:)
let's to look at a simple example :


string[] lines = File.ReadAllLines(txtProxyListPath.Text);
List<string> list_lines = new List<string>(lines);
foreach (string line in list_lines)

PHP Foreach array as a error in function (invalid argument for foreach in…)
by jaredsmiller in Programming Languages

Im working on a new minimal Project, but i've got an error, i dont know why.


Normally, i use arrays after i first created them with $array = array();


but in this case i create it without this code, heres an example full code, which outputs the error:


<?php $i = array('demo', 'demo'); $array['demo/demodemo'] = $i; ?>
<?php $i = ar

Rewrite nested foreach with linq if there are some operations apart from internal foreach loops
by raven84 in Programming Languages

I have following code and would like to translate it to linq. Is it possible, considering the two foreach loops inside the external foreach? Currently I could only translate the internal foreach loops to linq but still code is so long that I think that it might be shorter.


List<complexType> listOfComplex = ...some list...
List<complexType> newListOfCOmplex = new

Changing foreach loops to Parallel.ForEach and weird bugs
by acheron in Programming Languages

I have several loops that I wrote using the traditional syntax


foreach(x in xs) {....}

Some of these loops are pretty intensive in terms of computation and I just changed them using the parallel syntax like this:


Parallel.ForEach(x, xs => {...});

I see a major increase in performance!! Now my question is this: Am I intro


C#: Any benefit of List<T>.ForEach(…) over plain foreach loop?
by Bunny loves data in Programming Languages

I'm wondering why List<T>.ForEach(Action<T>) exists.


Is there any benefit/difference in doing :


elements.ForEach(delegate(Element element){ element.DoSomething(); });

over


foreach(Element element in elements) { element.DoSomething();}

?


LINQ Advice - Using ToList().ForEach instead of 'classic' ForEach iteration
by Alec in Programming Languages

I would like to use LINQ's ForEach construct and am not sure how to convert the following.


My current implementation:


var employees = (from e in employeeDepartmentList select e.Employee).ToList();
employeeList = new EmployeeList();
foreach (var emp in employees)
{
employeeList.Add(emp);
}

I am thinking something like th


php5 script upgrade - foreach inside foreach
by Matthias in Programming Languages

I'm trying to upgrade a script from PHP4 to PHP5 and I'm having an issue with foreach. I have looked online and haven't been able to find anything which works for my script.


Basically, the issue is that $filmid on line 9 and $event['venueID'] on line 13 are not recognised and the array returns empty.
I can make it work by assigning values to $fi


How to modify a foreach iteration variable from within foreach loop? (C#)
by soonk in Programming Languages

When I try to do this...


foreach(var item in twoDimArray)
{
item = new Item();
}

...I get Cannot assign to 'item' because it is a 'foreach iteration variable'.


Still, I'd like to do that.


The idea is to assign default Item class values to existing item.


UPD: Ite


Changing element value in List<T>.ForEach ForEach method
by Valentine in Programming Languages

I have the following code:


newsplit.ToList().ForEach(x => x = "WW");

I would expect that all elements in the list are now "WW" but they are still the original value. How come? What do I have to do different?


Next



Privacy Policy - Copyrights Notice - Feedback - Report Violation - RSS 2017 © bighow.org All Rights Reserved .