473,503 Members | 12,367 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Cannot iterate through an object collection.

59 New Member
Hey guys.
I'm building an object collection which will be a part of a Data Access Layer i am currently working on. However, i am having some issues iterating through a collection.
This is what i've done so far
1 - Create 'user' class which maps to the MySQL table. The class has basic setters and getters to set/get each field value.
2 - Created a collection class with simple add/remove/get methods.
3 - Created user collection class which extends my collection class described above. This user collection class overwrites addItem() method to achieve adding item of type 'user' to my user collection.
4 - Created collection iterator class which implements Iterator interface and overwrites its basic methods such as rewind/next/current and etc.
5 - Changed my collection class to implement IteratorAggregate interface.

At this point i should be able to use foreach() operator on my collection object but i can't. In fact, it doesn't even go into the foreach loop.

Here is the source: dowload

you can see i was testing foreach in the user collection class.

I appreciate any help i can get on this.
Dec 25 '07 #1
3 2260
pbmods
5,821 Recognized Expert Expert
Heya, Gasfusion.

foreach only works on public data members when used on a class instance.

Check out the ArrayObject class.
Dec 25 '07 #2
gasfusion
59 New Member
I've recoded all classes and got it to work. Have no clue what it was that was wrong.
Thanks.
Dec 28 '07 #3
pbmods
5,821 Recognized Expert Expert
Heya, Gasfusion.

Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)
Dec 30 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

4
10280
by: nc | last post by:
My iterator can find my collection when my Action class calls my jsp directly, however when my Action class calls an html file that is set up with IFrames (one of which is loading that same jsp), I...
1
6441
by: | last post by:
I'm going a little crazy trying to learn how to use arrays as properties in VBScript classes. Hopefully someone can help. First, I can't figure out whether it's possible to iterate through the...
3
11899
by: Billy Porter | last post by:
Greetings, If I populate an ArrayList with values from, let's say, the Keys enum: ArrayList a = new ArrayList(); a.Add(Keys.Home); a.Add(Keys.End); ....then how do I iterate through the...
2
4228
by: Chris Hayes | last post by:
Is it possible to iterate through all the active sessions of an ASP.net application? I have this fancy user object (with all kinds of properties) that I set as a session level object on session...
2
1948
by: James Doran | last post by:
Hello, I'd like to iterate through each Page of my ASP.NET project from within a Custom web control and access the Page.Controls collection. I've tried using Reflection on the web project...
7
5039
by: Rich | last post by:
Hello, I have a form with 5 textboxes named txt0, txt1, txt2, txt3, tx4. In VB6 I could iterate through these with For i = 0 to 4 debug.print Me.controls("txt" & i).Name Next
11
4477
by: Boni | last post by:
Dear all, following code iterates thru the hash table. Dim _Enumerator As IDictionaryEnumerator = _myhashtable.GetEnumerator While _Enumerator.MoveNext() ....
0
2497
by: chongming | last post by:
Hi, i want to display all the filenames on browser. However i found that if there are many filenames in that folder, result will be it will display a long list of filenames on that browser. My...
4
5579
by: Peted | last post by:
Hi I need to iterate through a winforms visible datagrid, in a legacy application, to update it a little bit to change the background colours of the grid. This seems to be more dificult than...
0
7098
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
7296
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,...
0
7364
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7470
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
5026
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4696
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3186
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1524
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.