Hi,
How to create an ArrayList from a System.Array or inserting the System.Array
into the ArrayList ?
Thanks
Ole 7 2929
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.co m
"ORC" <or*@sol.dk> wrote in message
news:en******** ******@TK2MSFTN GP10.phx.gbl... Hi,
How to create an ArrayList from a System.Array or inserting the System.Array into the ArrayList ?
Thanks Ole
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******** ******@TK2MSFTN GP10.phx.gbl... Hi,
How to create an ArrayList from a System.Array or inserting the
System.Array into the ArrayList ?
Thanks Ole
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(IColle ction).
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
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.co m> wrote in message
news:MP******** *************** *@msnews.micros oft.com... 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(IColle ction).
-- Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
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.co m
"ORC" <or*@sol.dk> wrote in message
news:%2******** ********@tk2msf tngp13.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.co m> wrote in message news:MP******** *************** *@msnews.micros oft.com... 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(IColle ction).
-- Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
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.c om> wrote in
message news:u7******** ******@TK2MSFTN GP11.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.co m "ORC" <or*@sol.dk> wrote in message news:%2******** ********@tk2msf tngp13.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.co m> wrote in message news:MP******** *************** *@msnews.micros oft.com... 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(IColle ction).
-- Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet If replying to the group, please do not mail me too
I will start a new thread with my last question.
"ORC" <or*@sol.dk> wrote in message
news:uo******** ******@TK2MSFTN GP14.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.c om> wrote
in message news:u7******** ******@TK2MSFTN GP11.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.co m "ORC" <or*@sol.dk> wrote in message news:%2******** ********@tk2msf tngp13.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.co m> wrote in message news:MP******** *************** *@msnews.micros oft.com... > 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(IColle ction).> > -- > Jon Skeet - <sk***@pobox.co m> > http://www.pobox.com/~skeet > If replying to the group, please do not mail me too
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 asp table.
The asp table has numerous rows and each row has a label item within it.
Im finding it impossible to get something to work which adds the newest item
in the array list to the next row in the asp table. the first time the
button is...
|
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(), _
System.Xml.Serialization.XmlArrayItem("User", GetType(User))> Public
arrUserList As New ArrayList
Private Function InitializeList() As ArrayList
|
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 the elements will move up one position. This will
be called a lot, so looking for speed. This just saving the index 0 as tmp
and then enum the list to move up the elements, then put the tmp object in
last pos is the best way? Cheers
--...
|
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 code below):
(a)When adding BitArrays to the ArrayList and then looping through the
ArrayList I seem to access only the latest added BitArray and I'm not exactly
clear on best way to access each BItArray in the ArrayList
(b)When I try to remove...
|
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 = dtLCPack.NewRow();
int intColCount = dtLCPack.Columns.Count;
ArrayList arrlRow = (ArrayList)alLCPlist; <== Specified cast
| |
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 textboxes have the
"lastname,first name" and the phone in the other one. Now I am stumpped
about how to write the instrucution to modify a record of the arraylist.
here is the whole code.
Imports Microsoft.VisualBasic
Imports System.IO
Imports...
|
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 learning and really need some help
bad.
Public Shared Function GetAll() As ArrayList
Dim dsCustomer As New DataSet()
Dim sqlQuery As String = "SELECT Name, Address, PhoneNo " & _
"FROM CustomerTable"
Try
|
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 arraylist then I have to handle this
with a sort method that uses comparer. I can reference the properties of the
Arraylist directly such as
dim mylist as new FrameList
mylist.Add(new FrameStructure)
mylist(0).first = "blabla..."
mylist(0).second...
|
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 storage and dynamically resize it when
there is a new point or should I use ArrayList? Is speed noticable between
the two?
Regards,
|
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 lot faster with both methods
using .NET 1.1, that's why I am pretty sure its a (rather serious) bug. Below
you can find C# test case that should allow you to reproduce this error, to
run it you will need to put 2 data files into current directory...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
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...
|
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...
|
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();...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |