473,657 Members | 2,932 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Merge the contents of one arraylist into another.

I have a function that returns an arraylist.

I want the returned arraylist to be copied into the local arraylist.
What is the most efficient way of doing this?

-Peter

Nov 21 '05 #1
11 16446
"pmclinn" <pe***@mclinn.c om> schrieb:
I want the returned arraylist to be copied into the local arraylist.
What is the most efficient way of doing this?


Assuming 'al1' and 'al2' are variables pointing to different arraylists, and
'al2''s content should be added to 'al1':

\\\
al1.AddRange(al 2)
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2
Hi Peter,

is the array list you return already filled? or is it an empty one, if it's
empty you can do it like this

Private Sub button1_Click(B yVal sender As System.Object, ByVal e As _
System.EventArg s) Handles button1.Click
Dim arr As New ArrayList
arr = GiveArraylist()
For i As Integer = 0 To arr.Count - 1
MsgBox(arr(i))
Next
End Sub

Private Function GiveArraylist() As ArrayList
Dim arr As New ArrayList
arr.Add("value1 ")
arr.Add("value2 ")
arr.Add("value3 ")
Return arr
End Function

hth Peter
"pmclinn" <pe***@mclinn.c om> wrote in message
news:11******** *************@c 13g2000cwb.goog legroups.com...
I have a function that returns an arraylist.

I want the returned arraylist to be copied into the local arraylist.
What is the most efficient way of doing this?

-Peter

Nov 21 '05 #3
Just use arrayList.Add. There is an overload that takes another arraylist.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"pmclinn" <pe***@mclinn.c om> wrote in message
news:11******** *************@c 13g2000cwb.goog legroups.com...
I have a function that returns an arraylist.

I want the returned arraylist to be copied into the local arraylist.
What is the most efficient way of doing this?

-Peter

Nov 21 '05 #4
Bob,

"Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > schrieb:
Just use arrayList.Add. There is an overload that takes another arraylist.


Are you sure about this? I don't see this overload for .NET 1.1.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #5
OOPs.. Red herring..Wrong API.

You need to use AddRange.

private void Form1_Paint(obj ect sender, System.Windows. Forms.PaintEven tArgs
e)

{

ArrayList a=new ArrayList();

ArrayList b=new ArrayList();

a.Add("One");

a.Add("Two");

a.Add("Three");

a.Add("Four");

a.Add("Five");

b.Add("Six");

b.Add("Seven");

b.Add("Eight");

b.Add("Nine");

b.Add("Ten");

a.AddRange(b);

int y=10;

foreach(string s in a)

{

e.Graphics.Draw String(s,Font,B rushes.Black,10 ,y);

y+=(int)Font.Ge tHeight()+4;

}
--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"pmclinn" <pe***@mclinn.c om> wrote in message
news:11******** *************@c 13g2000cwb.goog legroups.com...
I have a function that returns an arraylist.

I want the returned arraylist to be copied into the local arraylist.
What is the most efficient way of doing this?

-Peter

Nov 21 '05 #6
Brain fade on my part. Sorry.

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:uF******** ******@tk2msftn gp13.phx.gbl...
Bob,

"Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > schrieb:
Just use arrayList.Add. There is an overload that takes another
arraylist.


Are you sure about this? I don't see this overload for .NET 1.1.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #7
Bob,

"Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > schrieb:
OOPs.. Red herring..Wrong API.

You need to use AddRange.


Wrong programming language now :-))).

SCNR

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Nov 21 '05 #8
You can tell I'm having a bad day can't you :-(

--
Bob Powell [MVP]
Visual C#, System.Drawing

Find great Windows Forms articles in Windows Forms Tips and Tricks
http://www.bobpowell.net/tipstricks.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/faqmain.htm

All new articles provide code in C# and VB.NET.
Subscribe to the RSS feeds provided and never miss a new article.

"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:ud******** ******@TK2MSFTN GP09.phx.gbl...
Bob,

"Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > schrieb:
OOPs.. Red herring..Wrong API.

You need to use AddRange.


Wrong programming language now :-))).

SCNR

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #9
>> I want the returned arraylist to be copied into the local arraylist.
What is the most efficient way of doing this?


Assuming 'al1' and 'al2' are variables pointing to different arraylists,
and 'al2''s content should be added to 'al1':

\\\
al1.AddRange(al 2)
///

Are you sure this method is "copying", I have another idea (for copying I
am used to talk about values not references)

Cor
Nov 21 '05 #10

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

Similar topics

2
1470
by: Tommy | last post by:
Is it possible for a webpage to update itself based on what is present on another page. By this I mean that if the contents of page #2 is changed, then page #1 will load with the new information from page #2 instead of the old one. Thanks, Marc
3
1900
by: Deborah V. Gardner | last post by:
I would like to use conditional formatting on a subform and have 2 textbox affected. ItemID Qty Cost OrderDate 123 1 10.00 3/3/05 345 2 5.00 3/2/05 678 1 7.00 3/3/05 In the above example, if the date in a combo box is 3/3/05, I want the text in ItemID and OrderDate to be green for just those records with an
3
2109
by: VM | last post by:
How can I copy the contents of one datatable to another datatable? I've already the source table so I only need to copy its rows. Thanks.
1
1354
by: VMI | last post by:
How can I copy the contents of a directory without having to 1) create dir, 2)copy files ,etc...? Thanks.
2
1447
by: Jedi10180 | last post by:
I have a combo box that has 5 categories in it. When a user clicks on a category in that list, I need to have a second box populate with a list of pdf files that relate only to that category. Then, when the user clicks on the appropriate pdf file, I need the file to open in Adobe Reader. How can I make this happen? Is it a matter of including the entire list of all pdf files available in the second box and then somehow filtering them by the...
7
2005
by: MN | last post by:
I am using a program called IDWorks which is reading and writing to an MS Access format database. The IDWorks program can't adjust the formatting on a displayed field in a way that we need so I need a way to duplicate a field in Access so that it will have the exact copy of the other field. Is there some way to have a field definition set up so that it has the exact same contents? (ex. an entry such as "="). For that second field, is there...
8
1399
by: toton | last post by:
Hi, I am facing problem some times, and not finding a suitable answer to solve it. I have a vector (or some other container, sometimes) of some class, named CC like vector<CCv, NOT vector<CC*; I want another class say Segment to refer a portion of this vector. I can't store the iterator for vector as a member function to the class, as
1
1915
LacrosseB0ss
by: LacrosseB0ss | last post by:
Hey folks; I have 2 forms (form1 and form2). Form2 is a print view of Form1. The user fills out form1 (textboxes and such) and submits to Form2 for reviewing/printing before submitting to a database. I am trying to go the other way, from Form2 to Form1 for revising and such. However, all the objects on Form2 are labels and the contents of these are not passed. Can labels not be posted using form method=post ? I would try using javascript...
1
1713
by: rency | last post by:
hi friends, Please give me solution if u have..it is very urgent for me! i have folders as a |....a1 |...... |...test.txt |
0
1200
by: David Brey | last post by:
I am in the process of creating a database in Access 2007 to manage changes to products. I am a fairly new use of Access and would appreciate your help in solving my problem. I am going to use my database to track and report on the status of Engineering Change Orders (ECOs). Every ECO has an ECO Number and has parts associated with it. Additionally, any one part can have multiple ECOs associated with it. The ECO_Table contains information...
0
8820
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8718
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8601
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7314
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6162
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5630
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4300
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1937
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1601
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.