473,397 Members | 1,961 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,397 software developers and data experts.

How to loop through two arraylist?

this is my data,

cinema1 4pm
cinema1 5pm
cinema1 7pm
cinema2 2pm
cinema2 4.45pm
cinema3 10.45am

These are 2 different coloumns which I get from a webservice which can be arranged into an arraylist or array.. Now what I need is..the data to be displayed as follows..

cinema1
4pm 5pm 7pm
-----------------
cinema2
2pm 4.45pm
-----------------
cinema3
10.45am
Jan 31 '11 #1
5 2465
GaryTexmo
1,501 Expert 1GB
I don't know if separate arrays are appropriate in this case... you need some way to directly associate the times to the cinema. You may want to look at a key value pair, or perhaps having new data type that you can put in an array.

Perhaps that data type can be something like...

Expand|Select|Wrap|Line Numbers
  1. public class ScheduleItem
  2. {
  3.   public string CinemaName { get; set; }
  4.   public List<DateTime> ShowTimes { get; set; }
  5.   ...
  6. }
Then you can have a list of ScheduleItems and output accordingly?

If you absolutely must use two independent arrays, you will need something else to define how your data maps together...
Jan 31 '11 #2
I could even do it using Dictionary..can u help me in that
Feb 1 '11 #3
GaryTexmo
1,501 Expert 1GB
You can, yes... but your value will still have to be another object, which are a list of times. Here is the MSDN page for a Dictionary, have a read and give it a try. If you run into problems, post what you've got and we'll take a look.

http://msdn.microsoft.com/en-us/library/xfhwa508.aspx
Feb 1 '11 #4
NitinSawant
270 100+
use Linq group by clause on both the arraylists
Feb 1 '11 #5
Thanks guys for your help...however..i have used a dictionary and two new arrays to store the data... my final output is like this..
arraylist1----arraylist2
Cinema1 ----4pm 5pm 7pm
Cinema2---- 2pm 4.45pm
Cinema3----10.45am

Now my next task is to print alternate values from these arraylist into a html table..

it should look like this
==============================
Cinema1
==============================
4pm 5pm 7pm
==============================
Cinema2
==============================
2pm 4.45pm
==============================
Feb 2 '11 #6

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

Similar topics

10
by: Eric | last post by:
I'm looking at this page in the MSDN right here: ms-help://MS.MSDNQTR.2003FEB.1033/cpref/html/frlrfsystemcollectionsarraylist classsynchronizedtopic2.htm (or online here:...
5
by: David C | last post by:
This is very strange. Say I have code like this. I am simply looping through a collection object in a foreach loop. Course course = new Course(); foreach(Student s in course.Students) {...
4
by: tma | last post by:
I'm trying to save code to a session object like the following: dim oAppList as arraylist dim oApp as someclass Code to manipulate oApp... .... .... oApplist.Add(oApp)...
4
by: Mike | last post by:
I have declared two classes. The first class has 4 private variables. Each has a property defined. I'm calling a readfile sub from a second class. The second class also has an Arraylist...
4
by: blisspikle | last post by:
The following sub form1_load reads in a text file that will say something like the text below. I think that the problem is that every time I add a class V_Sensor into the arraylist it puts it in...
5
by: Paul | last post by:
Off the cuff, does anyone know if arraylist is more efficeint at adding items to an array than redim preserve? Paul <begin loop> Dim c As Integer = SomeArray.GetUpperBound(0) + 1 ReDim...
9
by: Andreas Schmitt | last post by:
I am somewhat new to C# and I ran into a problem in a small program I am writing for teaching myself. I am handling a list ob objects and I want to delete some of them inside a loop like in: ...
1
by: Doug_J_W | last post by:
I have a Visual Basic (2005) project that contains around twenty embedded text files as resources. The text files contain two columns of real numbers that are separated by tab deliminator, and are...
7
by: Kamran Shafi | last post by:
Hi, I am creating an arraylist (say masterArrayList) of hashtables, where each hashtable (say table) is of the format key=string, value = arraylist of strings (say existing_strings). In a...
32
by: falconsx23 | last post by:
I am making a game called Set, it is a card game: here is a brief description of the rules: The game of Set is played with 81 cards, each of which has 4 properties (number, pattern, color and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.