473,473 Members | 1,782 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Integers in ArrayList

Hi,

How, I would like to make a collection of integers. As an
integer is not a class I can't figure out how to store it
in a collection. The list will be generated dynamically.
Any suggestions.

int i = new int()
i = 5;
arrayList.Add(i) ... Seems to compile, but is this a
reccomended way to do it?

best regards Jesper.
Nov 15 '05 #1
1 5727
Jesper <je****@hotmail.com> wrote:
How, I would like to make a collection of integers. As an
integer is not a class I can't figure out how to store it
in a collection. The list will be generated dynamically.
Any suggestions.

int i = new int()
i = 5;
arrayList.Add(i) ... Seems to compile, but is this a
reccomended way to do it?


The above will work, but will take much more memory, because each value
is boxed. Unless you write your own version of ArrayList which stores
the values as an int[] however, you're not going to do much better. I
seem to remember that someone may have a tool somewhere to generate
collections like that automatically, but I don't have a URL for you.

I can't remember offhand whether the generics in the next version of
..NET will fix this problem or not, but it'd be nice if they did :)

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

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

Similar topics

1
by: Graeme Downes | last post by:
I have a string of integer, such as the following: "12 24 12 9 2" and I want to convert this into an array or arraylist which will seperate the string into an array of integers. How do I do...
5
by: rodchar | last post by:
Hey all, I have an array of numbers. What's the best way to get those numbers into one text field semicolon delimited? thanks , rodchar
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...
2
by: N! Xau | last post by:
Hi, I have this test: If Now().Subtract(AlBoxOutTime(0)) > Math.Ceiling(8 / 10 * AlBolPS(0) * AlTimerInt(0)) Then What I want to do is to test if the time difference between now() and a...
2
by: csgraham74 | last post by:
Hi Guys, Just wondering if someone could help me with an arraylist issue. I have an array of integers Arraylist 4 , 2, 11, 2, 21, 3 ,15 , 30 i want the arraylist to now be sorted...
2
by: Earl | last post by:
I'm trying to do a cast and I'm not sure where I'm going wrong here. I load up the ColorExtIntID column (int) into a list array (no problem there). For binding to a 3rd party component, it has to...
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...
1
by: xvader | last post by:
Hi, I'm new here, and I'm having a problem implementing a multiplication method for a class called VeryLongInt. It's for a homework problem. As far as I know, it should work just like the Bignum...
3
by: ApeX | last post by:
hi guys! So here i have two arraylists with the following structure (year, month, day)... What's the best way to calculate difference between the two? Example arraylist1 - 12y, 1m, 10d...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...
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,...
0
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.