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

Arraylist

I have 2 arraylists (name and value). Is there anyway that I can make that
into one arraylist with 2 columns. First column as name and second column as
value?

-- Steven
Nov 16 '05 #1
7 2547
You are talking about a DictionaryEntry item. You will have to iterate
through your arrays and create a separate array of DictionaryEntry objects.
Or you can just add them to a a dictionary or hashtable collection.
"Steven" <counterball_20122@_hotmail.com> wrote in message
news:Od**************@tk2msftngp13.phx.gbl...
I have 2 arraylists (name and value). Is there anyway that I can make that
into one arraylist with 2 columns. First column as name and second column as value?

-- Steven

Nov 16 '05 #2
Steven,

Why not use a Dictionary? Or, use a dataset, and place the values in
there (assuming that each arraylist contains the same type).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Steven" <counterball_20122@_hotmail.com> wrote in message
news:Od**************@tk2msftngp13.phx.gbl...
I have 2 arraylists (name and value). Is there anyway that I can make that
into one arraylist with 2 columns. First column as name and second column
as value?

-- Steven

Nov 16 '05 #3
My ultimate goal is to display the values in final Arraylist or Dictionary
item on my aspx page using datalist control. I dont know exactly on how to
iterate through the arrays and create a dictionary? How can I do that ?
Could you please explain a bit elaborately?

Thanks for the replies
Steven

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2*****************@TK2MSFTNGP10.phx.gbl...
Steven,

Why not use a Dictionary? Or, use a dataset, and place the values in
there (assuming that each arraylist contains the same type).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Steven" <counterball_20122@_hotmail.com> wrote in message
news:Od**************@tk2msftngp13.phx.gbl...
I have 2 arraylists (name and value). Is there anyway that I can make that
into one arraylist with 2 columns. First column as name and second column
as value?

-- Steven


Nov 16 '05 #4
Hi Steven,

Arraylists are one-dimensional only.
If you want it to be multidimensional you need to create an object
(class/struct) that holds the information you want.

You could possibly transfer your arraylists via two one-dimensional arrays
into a two dimensional-array using ArrayList.ToArray and Array.Copy, but
you won't end up with an ArrayList and the time spent on doing this
transformation would probably not be worth it as iterations will do the
same in about the same amount of time.

On Mon, 21 Mar 2005 11:39:37 -0800, Steven
<counterball_20122@_hotmail.com> wrote:
I have 2 arraylists (name and value). Is there anyway that I can make
that
into one arraylist with 2 columns. First column as name and second
column as
value?

-- Steven


--
Happy Coding!
Morten Wennevik [C# MVP]
Nov 16 '05 #5
Steven wrote:
My ultimate goal is to display the values in final Arraylist or Dictionary
item on my aspx page using datalist control. I dont know exactly on how to
iterate through the arrays and create a dictionary? How can I do that ?
Could you please explain a bit elaborately?
[you can just do this:
you can create a HashTable, or you can inherit your own dictionary from
DicitonaryBase.
for(int i =0; i< Count ; i++)
{
//get each value in the ArrayList and insert it into the dictionary.

}

you can also use a enumerator to loop through.
]
Thanks for the replies
Steven

"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:%2*****************@TK2MSFTNGP10.phx.gbl...
Steven,

Why not use a Dictionary? Or, use a dataset, and place the values in
there (assuming that each arraylist contains the same type).

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Steven" <counterball_20122@_hotmail.com> wrote in message
news:Od**************@tk2msftngp13.phx.gbl...
I have 2 arraylists (name and value). Is there anyway that I can make that
into one arraylist with 2 columns. First column as name and second column
as value?

-- Steven



Nov 16 '05 #6
Steven

You can create a class with two properties and set the instanced objects
from that in your arraylist.

I hope this helps,

Cor
Nov 17 '05 #7
Try the "NameValueCollection" in the System.Collections.Specialized
namespace.

Hope this helps,
Joe
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
Nov 17 '05 #8

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

Similar topics

7
by: Alex Ting | last post by:
Hi Everybody, I have an issue about deleting an object from an arrayList. I've bounded a datagrid using this code where it will first run through all of the code in loadQuestions() and bind a...
3
by: Stephen | last post by:
I was wondering if someone can help me with an web application design problem. I have a aspx page which builds up an arraylist called addresses and outputs the values in the arraylist items to a...
6
by: gane kol | last post by:
Hi, I have a code that creates a datatable from an arraylist, but i am getting an error in casting in for (int intRow = 0; intRow < alLCPlist.Count; intRow++) { DataRow drow =...
4
by: Peter | last post by:
I run into this situation all the time and I'm wondering what is the most efficient way to handle this issue: I'll be pulling data out of a data source and want to load the data into an array so...
18
by: JohnR | last post by:
From reading the documentation, this should be a relatively easy thing. I have an arraylist of custom class instances which I want to search with an"indexof" where I'm passing an instance if the...
18
by: Sam | last post by:
Hi All I'm planing to write an application which allows users dynamically add their points (say you can add upto 30,000) and then draw xy graph. Should I use an array for my coordinate point...
6
by: fniles | last post by:
I am using VB.NET 2003 and a socket control to receive and sending data to clients. As I receive data in 1 thread, I put it into an arraylist, and then I remove the data from arraylist and send it...
3
by: Christopher H | last post by:
I've been reading about how C# passes ArrayLists as reference and Structs as value, but I still can't get my program to work like I want it to. Simple example: ...
1
by: =?Utf-8?B?SkI=?= | last post by:
Hello My pgm1 (User Interface Level) passes an empty ArrayList to pgm2 (Business Logic Level). pgm2 then calls pgm3 (Data Access Level) to populate the ArrayList. Question1: When pgm2 gets...
0
by: Kate Horan | last post by:
Hi i have created a class called myArrayList with many methods, I'm now trying to run this class but im getting the error (illegal start of expression), could someone please help me out because im...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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
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?

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.