C# Loop limited to 50 passes
How do I limit the loop below to 50 so it stops when it reaches the 51st item? foreach (ListViewItem lvi in listView.Items) { } Thanks ...
How do I limit the loop below to 50 so it stops when it reaches the 51st item? foreach (ListViewItem lvi in listView.Items) { } Thanks ...
How can I add a new key/value pair to an existing array inside of nested foreach loops and have that pair persist outside the scope of the loops? <?PHP include('magpierss/rss_fetch.inc'); /* one, two, skip a few... $urls is an associative array with database indices as keys and URLs as values ...
In a normal loop you can break out of a loop using break. Can the same be done using an anonymous delegate? Example inputString and result are both declared outside the delegate. blackList.ForEach(new Action<string>( delegate(string item) { if(inputString.Contains(item)==true) { result = true; ...
I am creating a web application that acts as a priority list, allowing a user to re-arrange a set of items in a list and storing that arrangement in a MySQL database via a PHP backend. At the moment, when the user has finished arranging their items and saves the configuration, I am calling a seperate UPDATE statement for every row, plug...
I'm building this report in a system for a Billboard company. They have a table that stores all their billboards, and among other data, billboards have a Start Date and a Finish Date (both can be null). If for some reason a billboard has to stop beeing used, they set a finish date and it will become unnavaiable to be used after that date...
I´m trying to break a number into an array of numbers (in php) in the way that for example: 25 becomes (16, 8, 1) 8 becomes (8) 11 becomes (8, 2, 1) I don´t know what the correct term is, but I think the idea is clear. My solution with a loop is pretty straightforward: $number = rand(0, 128); $number_array_loop = array();...
How do I make nested loops in Python (version 3.0)? I am trying to get the following loops to show me the products of two numbers: def PrintProductsBelowNumber(number): number1 = 1 number2 = 1 while number1 <= number: while number2 <= number: print(number1, "*", number2, "=", number1 * number2) ...
Hi, I have an array of files in the object FileInfo[]. In my service, I am currently looping through the files and processing them. I want to loop through the files, and remove them from the collection as they are processed. I think a queue is ideal for this, but how can I loop through a queue collection? (never used a queue in C# ...
I recently wrote a small number-crunching program that basically loops over an N-dimensional grid and performs some calculation at each point. for (int i1 = 0; i1 < N; i1++) for (int i2 = 0; i2 < N; i2++) for (int i3 = 0; i3 < N; i3++) for (int i4 = 0; i4 < N; i4++) histogram[bin_index(i1, i2, i3, i4)] += 1; // see b...
I'm doing some Wave file handling and have them read from disk into an array of bytes. I want to quickly copy portions from this byte array into another buffer for intermediate processing. Currently I use something like this: float[] fin; byte[] buf; //fill buf code omitted for(int i=offset; i < size; i++){ fin[i-offset] = (float) bu...
What I'm looking for is something like: @list = qw(1 2 3 4 5 6) foreach (@list) { #perl magic goes here print "i: $i, j:$j\n"; } returns: i:1, j:2 i:3, j:4 i:5, j:6 In response to a very good suggestion below, I need to specify that this script will run on someone else's build server, and I'm not allowed to use any modules from...
There seem to be three main ways to output content from Wordpress using its built-in functions, with WP_Query being the recommended one: WP_Query query_posts get_posts What are the differences between them? (I understand that WP_Query is the class, and the other two are methods). What is the cleanest way to have multiple loops on th...
Hi, I'm working on a web form where I wish to (after form submission) highlight those input fields that weren't entered correctly. The highlight effect I wish to create is an endlessly looping animation between background-color: #fcc; and #fff; in the faulty input fields, using jQuery. When one of those fields gain focus, I wish to stop...
Okay, I tested this on an empty program, and just having a while(true){} running gave me >50% on my CPU. I have a game I'm working on that uses a while loop as it's main loop, and it's CPU is at 100 all the time. How can I get Java to repeat something over and over without eating up >50% of my CPU just to do the repeating? ...
for i in range(0,3): j = 0 print 'incrementing ' j += 1 print j prints incrementing 1 incrementing 1 incrementing 1 How can I persist the value of 'j' so that it prints: 1 2 3 ...
I have a loop that is doing some error checking in my PHP code. Originally it looked something like this foreach($results as $result) { if (!$condition) { $halt = true; ErrorHandler::addErrorToStack('Unexpected result.'); } doSomething(); } if (!$halt) { // do what I want cos I know there was no error ...
Do you know a tool that automatically refactors a method with a single loop into a recursive method, preferably in Java? This is for teaching purposes. ...
Hi there. Im having a problem with a loop inside a C++ dll being called from VB. I want this loop to update a global variable, but when I call the function the variable does not update the first time round, but does so every subsequent time. This is how I am trying to update the variable. else { ::nScore = nHighest; if (nScor...
I'm just curious what peoples' thoughts are on this topic. Let's say I have an Array of Objects, and I want to loop through them to see if the Objects contain certain values, and if so, I want to stop the loop. Which is better practice - a for loop with a break, or a conditional loop? The pseudo-code in the example I have provided is fo...
Hello everyone, I have a type called Foo and it has a field called length. I want to write a single loop statement in Windbg which will dump length field of all object instances of type Foo in managed heap? thanks in advance, George ...