foreach

C# foreach loop causes CS 0246 Type or namespace could not be found

I have a foreach loop that cycles through a list of types and creates an instance of each one. However, when I build, it gives a CS0246 error ("The type or namespace could not be found ... "). Here's a simplified version of the code: internal static class TypeManager { internal static void LoadTypes() { // Fill the lis...

how to get the content of a variable from the last element

I was just wondering how I can get the content of a variable starting from the last value instead of the first ( using foreach), $variable = [1,2,3,4]; how can I print 4 then 3 and so on (if the size of the variable in unknown, is it possible to get the last value first). thanks ...

Print out the answers for a question by PHP

How can you use the following sample data either with a foreach or while -loop? I get the following sample data by running $answers = pg_fetch_all ( $result );. Sample data [0]=> array(3) { ["answer"]=> string(7) "This is the answer" ["username"]=> string(5) "roope" ["was_sent_at_time"]=> string(26) "2009-...

What is the best way to check a ListView for checked Items in C#?

Hi! I'm writing a Database Editor / Bill of Materials Maker (2 separate .exe) for work, and I have this crazy issue. Here's how the flow works in the apps: Open Database, Search Database, Check Items Needed, Send to BOM Maker, Save as .xls. So far, I can send checked Items to the BOM Maker, but only if I open the search window, check t...

Struts forEach tag not iterating through ArrayList

I have some code! The code looks like this: <c:forEach var="element" items="%{serviceList.getServices()}"> <p>Hello!</p> </c:forEach> "serviceList" is a bean, with a method on it called getServices(). getServices() returns an ArrayList, so I naturally assumed that the above code would take the arraylist, and iterate through it...

WPF ControlTemplate with foreach?

I currently try to create classes for a paint-like WPF application. I have to base classes LineMovement (line from StartPoint to EndPoint) and PathMovement (line going through all points specified in a property Points of type PointCollection). These classes inherit from Control and get their looks through a ControlTemplate. Now I want t...

For each loop in vb.net

Hello, How do I use for loop in vb.net something like dim start as integer Dim customers as New List(Of Customers) Customers=dataAcess.GetCustomers() For each start=500 in Customers.count 'Do something here' Next I want to process some data for each 500 customers.. Please help ...

.NET: ForEach() extension methods and Dictionary

Hello all I have a quick question: I do alot of iteration of Dictionary.Value collections and in annoys me that I have to call .ToList() to then be able to call .ForEach(), as it seems none of the enumerable collections in a Dictionary (The Dictionary itself, the Keys collection or the Values collection) have a ForEach extension method....

1 character only foreach loop result in PHP

Hello i have this foreach loop that gives weird result , it displays only the first character form the db record <?php $result2 = mysql_query("SELECT id,fp_thumb,title FROM media") or die(mysql_error()); $data2 = mysql_fetch_array($result2) or die(Mysql_error()); foreach ($data2 as $val) { echo '<li><a href="media.php?id='.$val['id...

Getting foreach() and ggplot2 to get along

I have a set of survey data, and I'd like to generate plots of a particular variable, grouped by the respondent's country. The code I have written to generate the plots so far is: countries <- isplit(drones, drones$v3) foreach(country = countries) %dopar% { png(file = paste(output.exp, "/Histogram of Job Satisfaction in ", country$ke...

How can i use different string value's in one function ?

Hello evertbody, First i am a beginner in programming in general, i am trying to create a program for using gps locations from Lightroom on a map in googlemaps. When i use the print the strings below ti the screen i see 5 different value's, this is also what i want, but... I want to create also 5 different markers on the map this is d...

C++ How to loop through a list of structs and access their properties

I know I can loop through a list of strings like this: list<string>::iterator Iterator; for(Iterator = AllData.begin(); Iterator != AllData.end(); Iterator++) { cout << "\t" + *Iterator + "\n"; } but how can I do something like this? list<CollectedData>::iterator Iterator; for(Iterator = AllData.begin(); Iterator != ...

java: how many times is the collection expression evaluated in a "foreach"

if I do this in Java: for(String s : myCollection.expensiveListGeneration()) { doSomething(); } is expensiveListGeneration() invoked just once at the beggining or in every cycle iteration? Is it implementation dependent? ...

Where is boost::lambda::ll?

Hi all, I can't seem to find boost::lambda::ll for a nested ll::for_each() invocations in any header file in the boost_1_39_0 distribution. Could someone point me to the right direction? Thanks. ...

jQuery append child nodes in for each

In the below code I'm trying to loop through each child node and append the child to another element - what is the correct syntax inside the loop? $(this).children().each( $(div).appendChild(this.childNodes.length - 1); ); ...

Fetching categories and items with Zend Framework

Hi all, Currently my code below works fine but it's a bit of overkill. In my controller I fetch the categories that have links and all the links in my database. In my view I loop through all the categories and then when I want to add the links under the category I loop through all the links in my database instead I should only loop thro...

Include the result of a Foreach loop in a variable in PHP ? ( for the function mail() )

Hi, I'm French so I maybe not speak english very well. I'm trying to "put" the result of a foreach loop in a varible like that : $msg = '<html><head> <title>Commande de photos</title> </head><body> <p>Voici la liste des photos demand&eacute;es :<br /> <ul> HERE I WANT TO "PUT" THE RESULT OF THE FOREACH LOOP</ul>'; H...

Creating a foreach keyword with yacc or Bison and Flex

I have developed a interpreted programming language. It is strongly based on C. The problem is, I want to add a foreach directive and have no clue how to. I am using Bison and Flex as the parser and lexer generator. ...

PHP,how to get current index in a foreach loop for array ?

How do I get the current index in a foreach loop? foreach( $arr as $key=>$val) { //how to get index? //how to get first element in an associated array } ...

mysql_list_tables into foreach array?

Is it possible to list my tables into a foreach array? current code. $browsers = array ("site1", "site2", "site3"); foreach($browsers as $browser) { $domain = $browser; include ('code.php'); } ...