473,386 Members | 1,764 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Alternative loop

Hello,

I'm doing the following.

IDictionaryEnumerator iter = Persons.GetEnumerator();

while ( iter.MoveNext() ) {
Person person = ( Persons ) iter.Value;
if ( person.SameAge( Age ) ) {
Persons.Remove( person.GetHashCode() );
}
}

Now I get an error.
The error says that I have changed the Persons collection.
This is correct. Because I removed a person.

How can I walk through all Persons?
With not using while ( iter.MoveNext() ).
Can you give me an example?

Thanks!
Nov 15 '05 #1
2 2274
Question solved with arraylist.

Thanks!

"Arjen" <bo*****@hotmail.com> schreef in bericht
news:bv**********@news3.tilbu1.nb.home.nl...
Hello,

I'm doing the following.

IDictionaryEnumerator iter = Persons.GetEnumerator();

while ( iter.MoveNext() ) {
Person person = ( Persons ) iter.Value;
if ( person.SameAge( Age ) ) {
Persons.Remove( person.GetHashCode() );
}
}

Now I get an error.
The error says that I have changed the Persons collection.
This is correct. Because I removed a person.

How can I walk through all Persons?
With not using while ( iter.MoveNext() ).
Can you give me an example?

Thanks!

Nov 15 '05 #2
I see you have solved your problem.
Just for information you may take a look on the solution provided in this
article
http://msdn.microsoft.com/library/de...rp01212002.asp

--
B\rgds
100

"Arjen" <bo*****@hotmail.com> wrote in message
news:bv**********@news1.tilbu1.nb.home.nl...
Question solved with arraylist.

Thanks!

"Arjen" <bo*****@hotmail.com> schreef in bericht
news:bv**********@news3.tilbu1.nb.home.nl...
Hello,

I'm doing the following.

IDictionaryEnumerator iter = Persons.GetEnumerator();

while ( iter.MoveNext() ) {
Person person = ( Persons ) iter.Value;
if ( person.SameAge( Age ) ) {
Persons.Remove( person.GetHashCode() );
}
}

Now I get an error.
The error says that I have changed the Persons collection.
This is correct. Because I removed a person.

How can I walk through all Persons?
With not using while ( iter.MoveNext() ).
Can you give me an example?

Thanks!


Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

46
by: Robin Becker | last post by:
It seems that the rotor module is being deprecated in 2.3, but there doesn't seem to be an obvious alternative. I'm using it just for obfuscation. It seems we have ssl available in 2.3 for sockets,...
24
by: Andrew Koenig | last post by:
PEP 315 suggests that a statement such as do: x = foo() while x != 0: bar(x) be equivalent to while True:
9
by: HikksNotAtHome | last post by:
This is a very simplified example of an Intranet application. But, is there an easier (or more efficient) way of getting the decimal equivalent of a fraction? The actual function gets the select...
1
by: prasaddevivara | last post by:
I am using the outerHTML property to modify the HTML of existin elements in a web page in Internet Explorer. But same outerHTM property is not working in firefox browser, Anybody can tell me a...
2
by: François de Dardel | last post by:
Please don't scream that EMBED is evil ! What I am doing is <EMBED SRC="BWV659.mid" AUTOSTART="false" LOOP="TRUE" CONTROLS="SMALLCONSOLE" WIDTH="50" HEIGHT="15" TITLE="BWV 659"> Note the...
3
by: Billy | last post by:
I wish to select a node using the value of one of its attributes, i.e. xml: .... <tablelist> <table name="table1"> ... </table> <table name="table2"> ...
0
by: Tom Warren | last post by:
I found a c program called similcmp on the net and converted it to vba if anybody wants it. I'll post the technical research on it if there is any call for it. It looks like it could be a useful...
1
by: Doug Arnott | last post by:
http://www.cs.rutgers.edu/~pxk/rutgers/notes/pdf/Cstyle.pdf has an example at the end of the document of an example of an alternative implementation of interest to me. In this example, the...
1
by: Leigh | last post by:
This is the query I have to update a column in one table, by comparing 2 of its columns to with the columns of another table. The WIE_Physician table has 1655 records, hence the loop, and the...
5
by: ElPresidente | last post by:
Now that I have your attention haha... I have this weekly file that contains several hundred invoices that need to be given batch letters in according to the following hierarchy. Employee...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.