473,326 Members | 2,126 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,326 software developers and data experts.

ArrayList and System.Array ?

ORC
Hi,

How to create an ArrayList from a System.Array or inserting the System.Array
into the ArrayList ?

Thanks
Ole
Nov 16 '05 #1
7 2900
Ole,

You can pass the array into the constructor of the ArrayList. It takes
an ICollection, which all arrays implement.

If you have a need to add an existing array to an array list, then you
can call the AddRange method, and pass the array through that.

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

"ORC" <or*@sol.dk> wrote in message
news:en**************@TK2MSFTNGP10.phx.gbl...
Hi,

How to create an ArrayList from a System.Array or inserting the
System.Array
into the ArrayList ?

Thanks
Ole

Nov 16 '05 #2
Array implements IList and ICollection. Take a look at the constructors for
ArrayList.

Or you could use AddRange with a blank list.

"ORC" <or*@sol.dk> wrote in message
news:en**************@TK2MSFTNGP10.phx.gbl...
Hi,

How to create an ArrayList from a System.Array or inserting the System.Array into the ArrayList ?

Thanks
Ole

Nov 16 '05 #3
ORC <or*@sol.dk> wrote:
How to create an ArrayList from a System.Array
As others have said, the constructor which takes an ICollection.
or inserting the System.Array into the ArrayList ?


I haven't seen any answers addressing this - use AddRange(ICollection).

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #4
ORC
Thank you all for your great help!

The AddRange perfectly fits my needs, but leads me to another question: is
it possible to add a part of a SystemArray to the ArrayList e.g. from index
0 to index n ?

Thanks
Ole

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
ORC <or*@sol.dk> wrote:
How to create an ArrayList from a System.Array


As others have said, the constructor which takes an ICollection.
or inserting the System.Array into the ArrayList ?


I haven't seen any answers addressing this - use AddRange(ICollection).

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 16 '05 #5
Ole,

No, it is not. The simplest way to do this would be to copy the
elements you want to add out to another array, then call AddRange, passing
that in.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"ORC" <or*@sol.dk> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Thank you all for your great help!

The AddRange perfectly fits my needs, but leads me to another question: is
it possible to add a part of a SystemArray to the ArrayList e.g. from
index
0 to index n ?

Thanks
Ole

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
ORC <or*@sol.dk> wrote:
> How to create an ArrayList from a System.Array


As others have said, the constructor which takes an ICollection.
> or inserting the System.Array into the ArrayList ?


I haven't seen any answers addressing this - use AddRange(ICollection).

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Nov 16 '05 #6
ORC
OK thanks! What about using an ArrayList in a call to a native DLL instead
off using a System.Array - will that be possible and is .NET able to marshal
it automatically?

Thanks,
Ole

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

No, it is not. The simplest way to do this would be to copy the
elements you want to add out to another array, then call AddRange, passing
that in.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"ORC" <or*@sol.dk> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Thank you all for your great help!

The AddRange perfectly fits my needs, but leads me to another question: is it possible to add a part of a SystemArray to the ArrayList e.g. from
index
0 to index n ?

Thanks
Ole

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
ORC <or*@sol.dk> wrote:
> How to create an ArrayList from a System.Array

As others have said, the constructor which takes an ICollection.

> or inserting the System.Array into the ArrayList ?

I haven't seen any answers addressing this - use AddRange(ICollection).

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too



Nov 16 '05 #7
ORC
I will start a new thread with my last question.
"ORC" <or*@sol.dk> wrote in message
news:uo**************@TK2MSFTNGP14.phx.gbl...
OK thanks! What about using an ArrayList in a call to a native DLL instead
off using a System.Array - will that be possible and is .NET able to marshal it automatically?

Thanks,
Ole

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

No, it is not. The simplest way to do this would be to copy the
elements you want to add out to another array, then call AddRange, passing
that in.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"ORC" <or*@sol.dk> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Thank you all for your great help!

The AddRange perfectly fits my needs, but leads me to another question:
is it possible to add a part of a SystemArray to the ArrayList e.g. from
index
0 to index n ?

Thanks
Ole

"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
> ORC <or*@sol.dk> wrote:
> > How to create an ArrayList from a System.Array
>
> As others have said, the constructor which takes an ICollection.
>
> > or inserting the System.Array into the ArrayList ?
>
> I haven't seen any answers addressing this - use

AddRange(ICollection).>
> --
> Jon Skeet - <sk***@pobox.com>
> http://www.pobox.com/~skeet
> If replying to the group, please do not mail me too



Nov 16 '05 #8

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

Similar topics

0
by: Stephen | last post by:
I have been getting on well with help from this forum trying to create an array list and work with it. Everything is working fine apart from displaying my array list items into the labels in my...
4
by: Christopher Pragash | last post by:
Hello all, Following is the code that I'm using to serialize an arraylist. This code returns an "Unknown" Errror. Any ideas would be of great help. <System.Xml.Serialization.XmlArray(), _...
7
by: William Stacey [MVP] | last post by:
I can think of a couple ways to do this, but was wonder what the fastest way you can think of. Want to take any arraylist of > 1 element and make the first element the last, and all the rest of...
9
by: vbportal | last post by:
Hi, I would like to add BitArrays to an ArrayList and then remove any duplicates - can someone please help me forward. I seem to have (at leaset ;-) )2 problems/lack of understanding (see test...
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 =...
2
by: RBCC | last post by:
I have a form with a 2 textboxes and a listbox, The data is read in by a file called "memberphones" The listnbox lists names in this way (lastname,first name) sorted by the last name. the...
16
by: Allen | last post by:
I have a class that returns an arraylist. How do I fill a list box from what is returned? It returns customers which is a arraylist but I cant seem to get the stuff to fill a list box. I just...
20
by: Dennis | last post by:
I use the following code for a strongly typed arraylist and it works great. However, I was wondering if this is the proper way to do it. I realize that if I want to implement sorting of 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...
48
by: Alex Chudnovsky | last post by:
I have come across with what appears to be a significant performance bug in ..NET 2.0 ArrayList.Sort method when compared with Array.Sort on the same data. Same data on the same CPU gets sorted a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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...

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.