Click here to Skip to main content
15,890,741 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Dear

I am trying to find out that
After every insertion in array
i want to change the size of that array without losing
previous data.

I tryed but the previous data is going out.

Is there any way to resolve it

Thank You in advance

Jagadeesh
Posted

If you want a variable length array,then you can use Arrarylist.
To use arraylist,
Firstly Import the namespace,
C#
System.Collections;

and the use Arraylist in following way,
C#
ArrayList arr = new ArrayList();
arr.Add("val1");
arr.Add("Val2");

One key advantage of using Arraylist over arrays is that they can grow and shrink as the number of stored objects changes.
 
Share this answer
 
v3
Try Redim Preserve Array(200)

Ron
 
Share this answer
 
Hi Jagadeesh,

Why you want to change your array size after every insertion in array? If you want to increase array size automatically then you should go for ArrayList in-spite of Array.

For more info on Array go through below link:
[Arrays in Asp.Net]

And For ArrayList :

[ArrayList in Asp.Net]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900