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

Really simple question: How to convert ArrayList of int to int[]?

As titled.
Nov 17 '05 #1
4 2906
How about ArrayList.ToArray(int)?

HTH
-Cliff

"Homa" <ho******@yahoo.com> wrote in message
news:a9**************************@posting.google.c om...
As titled.

Nov 17 '05 #2
If I do this, I will get an error:

Can't convert Array to int[]

Homa Wong

"Cliff Harris" <he***@myrealbox.com> wrote in message news:<Oz**************@TK2MSFTNGP09.phx.gbl>...
How about ArrayList.ToArray(int)?

HTH
-Cliff

"Homa" <ho******@yahoo.com> wrote in message
news:a9**************************@posting.google.c om...
As titled.

Nov 17 '05 #3
SSW
Try Below code...

ArrayList atl = new ArrayList(3);
atl.Add(1);
atl.Add(2);
atl.Add(3);
int[] i= (int[])atl.ToArray(System.Type.GetType("System.Int32"));

Hope this helps.

Thanks,

sswalia
MCAD, MCAD, OCA

"Homa" <ho******@yahoo.com> wrote in message
news:a9**************************@posting.google.c om...
As titled.

Nov 17 '05 #4
Thanks, that works now

Homa Wong
"SSW" <fr************@hotmail.com> wrote in message news:<#w**************@TK2MSFTNGP09.phx.gbl>...
Try Below code...

ArrayList atl = new ArrayList(3);
atl.Add(1);
atl.Add(2);
atl.Add(3);
int[] i= (int[])atl.ToArray(System.Type.GetType("System.Int32"));

Hope this helps.

Thanks,

sswalia
MCAD, MCAD, OCA

"Homa" <ho******@yahoo.com> wrote in message
news:a9**************************@posting.google.c om...
As titled.

Nov 17 '05 #5

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

Similar topics

6
by: Mimi | last post by:
Is there a way to convert int to byte easily? I want to write my int indexTbl to a MemoryStream but the MemoryStream class only accepts byte buffer. I have more than one int indexTbl to write...
3
by: Sky Sigal | last post by:
I coming unglued... really need some help. 3 days chasing my tail all over MSDN's documentation ...and I'm getting nowhere. I have a problem with TypeConverters and storage of expandableobjects...
0
by: han zhiyang | last post by:
I decide to make the problem clear from tip to toe. my test code is from Anders Heilsberg's lecture on Tech-Ed 2004 on C# Language enhancement. I slightly modified the code,not to the core part...
5
by: Galahad | last post by:
I am using the code below to create a integer array. while(dr.Read()) { string StateID=dr.ToString(); int FacilityID=Convert.ToInt32(dr.ToString()); int FacilityIDs={FacilityID}; } ...
4
by: None | last post by:
Hi, How can we convert ArrayList to Int (i.e., Integer Array). If anybody knows the solution pls let me know. Thanks and Regards, Vinothkumar B
26
by: nyathancha | last post by:
Hi, How Do I create an instance of a derived class from an instance of a base class, essentially wrapping up an existing base class with some additional functionality. The reason I need this is...
1
by: dev24 | last post by:
Hi all, I am writing a simple method which when entered with an Int parameter performs an sql query, creates a result set, uses that resultset to get values from the object created by another...
8
by: scottc | last post by:
i'm stuck and i need a little direction. i'm only getting 2 error messages. i have 2 files: import java.util.ArrayList; import java.util.*; //author public class StudentTester { ...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
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
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,...

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.