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

Resizing an arraylist

I have an arraylist of for example 1200. I want to re organize the
array so that position 1 on the arraylist if actaully now position 3
and i want to add 3 position before position 3 and at the end of the
arraylist. Can i use the Redim statement?
Jun 27 '08 #1
5 2134
"cmdolcet69" <co************@hotmail.comschrieb
I have an arraylist of for example 1200. I want to re organize the
array so that position 1 on the arraylist if actaully now position 3
and i want to add 3 position before position 3 and at the end of the
arraylist. Can i use the Redim statement?
The benefit in using an Arraylist is that you do _not_ have to (and
can't) ReDim anything. Use the Add/Insert/Remove/RemoveAt methods to
add/remove items. In VB 2005 and above, there are several additional
Generic lists, like List(Of T).
Armin

Jun 27 '08 #2
On May 5, 10:16*am, "Armin Zingler" <az.nos...@freenet.dewrote:
"cmdolcet69" <colin_dolce...@hotmail.comschrieb
I have an arraylist of for example 1200. I want to re organize the
array so that position 1 on the arraylist if actaully now position 3
and i want to add 3 position before position 3 and at the end of the
arraylist. Can i use the Redim statement?

The benefit in using an Arraylist is that you do _not_ have to (and
can't) ReDim anything. Use the Add/Insert/Remove/RemoveAt methods to
add/remove items. In VB 2005 and above, there are several additional
Generic lists, like List(Of T).

Armin
How can i add in 3 position at the start???
Jun 27 '08 #3
"cmdolcet69" <co************@hotmail.comschrieb:
I have an arraylist of for example 1200. I want to re organize the
array so that position 1 on the arraylist if actaully now position 3
and i want to add 3 position before position 3 and at the end of the
arraylist. Can i use the Redim statement?

The benefit in using an Arraylist is that you do _not_ have to (and
can't) ReDim anything. Use the Add/Insert/Remove/RemoveAt methods to
add/remove items. In VB 2005 and above, there are several additional
Generic lists, like List(Of T).

How can i add in 3 position at the start???
Take a look at 'ArrayList.Insert'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Jun 27 '08 #4
"cmdolcet69" <co************@hotmail.comschrieb
On May 5, 10:16 am, "Armin Zingler" <az.nos...@freenet.dewrote:
"cmdolcet69" <colin_dolce...@hotmail.comschrieb
I have an arraylist of for example 1200. I want to re organize
the array so that position 1 on the arraylist if actaully now
position 3 and i want to add 3 position before position 3 and at
the end of the arraylist. Can i use the Redim statement?
The benefit in using an Arraylist is that you do _not_ have to
(and can't) ReDim anything. Use the Add/Insert/Remove/RemoveAt
methods to add/remove items. In VB 2005 and above, there are
several additional Generic lists, like List(Of T).

Armin

How can i add in 3 position at the start???

Probably you are looking for the Insert method that I have mentioned
before.
Armin

Jun 27 '08 #5
I think this is what you are after:

Module Module1
Sub Main()
Dim arl As New ArrayList
'initialise
arl.Add(0)
arl.Add(1)
arl.Add(2)
arl.Add(3)
arl.Add(4)
arl.Add(5)
'move first two elements to the end
arl.Add(arl(0))
arl.RemoveAt(0)
arl.Add(arl(0))
arl.RemoveAt(0)

For Each o As Object In arl
Console.Write(o.ToString & " ")
Next
Console.ReadKey()

End Sub

End Module
--
David Streeter
Synchrotech Software
Sydney Australia

Jun 27 '08 #6

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

Similar topics

1
by: Neil Woodvine | last post by:
***Scenario ... I have a DataList with a hyperlink WebControl in the Item Template. I want to display a 64x64 image in the Hyperlink and set the NavigateURL to the full size image. ***Source...
7
by: Kjell | last post by:
H I'm a former VB programmer and I have a issue with Arrays in C If I can't tell the size in advance how can I solve the issue since C# does not suppor resizing arrays like VB do (i.e. Redim...
1
by: Neil Woodvine | last post by:
***Scenario ... I have a DataList with a hyperlink WebControl in the Item Template. I want to display a 64x64 image in the Hyperlink and set the NavigateURL to the full size image. ***Source...
4
by: John A Grandy | last post by:
As there is no ReDim in C# , what is the preferred technique for dynmically increasing the size of any array ? Does the answer depend on whether the array holds primitives versus instances of...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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:
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
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
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
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...
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...

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.