Hi,
How do we increase the size of array on runtime and preserve the previous
data?
I don't want to use ArrayList because the array could be a multi-dimension
array.
Thanks,
Tee 8 10606
You didn't specify what type of array but for a byte array you could use the
following method:
public byte [] ReDim(byte [] array, int newSize)
{
byte [] abytNew = new byte[newSize];
Buffer.BlockCop y(array, 0, abytNew, 0, newSize);
return abytNew;
}
Buffer.BlockCop y can handle any type inherited from Array:
byte []
int []
long []
etc...
HTH
"Tee" <th*@streamyx.c om> wrote in message
news:eD******** ******@TK2MSFTN GP10.phx.gbl... Hi,
How do we increase the size of array on runtime and preserve the previous data? I don't want to use ArrayList because the array could be a multi-dimension array.
Thanks, Tee
It will be a string array.
Thanks,
Tee
"mooni" <to*****@hotmai l.com> wrote in message
news:41******** @dnews.tpgi.com .au... You didn't specify what type of array but for a byte array you could use
the following method:
public byte [] ReDim(byte [] array, int newSize)
{
byte [] abytNew = new byte[newSize];
Buffer.BlockCop y(array, 0, abytNew, 0, newSize);
return abytNew;
}
Buffer.BlockCop y can handle any type inherited from Array:
byte [] int [] long []
etc...
HTH
"Tee" <th*@streamyx.c om> wrote in message news:eD******** ******@TK2MSFTN GP10.phx.gbl... Hi,
How do we increase the size of array on runtime and preserve the
previous data? I don't want to use ArrayList because the array could be a
multi-dimension array.
Thanks, Tee
Buffer.BlockCop y also applies to string arrays:
public string [] ReDim(string [] array, int newSize)
{
string [] astrNew = new string[newSize];
Buffer.BlockCop y(array, 0, astrNew, 0, newSize);
return astrNew;
}
HTH
mooni
"Tee" <th*@streamyx.c om> wrote in message
news:%2******** ********@TK2MSF TNGP14.phx.gbl. .. It will be a string array.
Thanks, Tee
"mooni" <to*****@hotmai l.com> wrote in message news:41******** @dnews.tpgi.com .au... You didn't specify what type of array but for a byte array you could use the following method:
public byte [] ReDim(byte [] array, int newSize)
{
byte [] abytNew = new byte[newSize];
Buffer.BlockCop y(array, 0, abytNew, 0, newSize);
return abytNew;
}
Buffer.BlockCop y can handle any type inherited from Array:
byte [] int [] long []
etc...
HTH
"Tee" <th*@streamyx.c om> wrote in message news:eD******** ******@TK2MSFTN GP10.phx.gbl... > Hi, > > How do we increase the size of array on runtime and preserve the previous > data? > I don't want to use ArrayList because the array could be a multi-dimension > array. > > > Thanks, > Tee > >
It gives error:
An unhandled exception of type 'System.Argumen tException' occurred in
WindowsApplicat ion10.exe
Additional information: Object must be an array of primitives.
if I comment out this Buffer.BlockCop y, it will work, but can't preserve the
old value.
Thanks.
"mooni" <to*****@hotmai l.com> wrote in message
news:41******@d news.tpgi.com.a u... Buffer.BlockCop y also applies to string arrays:
public string [] ReDim(string [] array, int newSize) { string [] astrNew = new string[newSize]; Buffer.BlockCop y(array, 0, astrNew, 0, newSize); return astrNew; }
HTH mooni
"Tee" <th*@streamyx.c om> wrote in message news:%2******** ********@TK2MSF TNGP14.phx.gbl. .. It will be a string array.
Thanks, Tee
"mooni" <to*****@hotmai l.com> wrote in message news:41******** @dnews.tpgi.com .au... You didn't specify what type of array but for a byte array you could
use the following method:
public byte [] ReDim(byte [] array, int newSize)
{
byte [] abytNew = new byte[newSize];
Buffer.BlockCop y(array, 0, abytNew, 0, newSize);
return abytNew;
}
Buffer.BlockCop y can handle any type inherited from Array:
byte [] int [] long []
etc...
HTH
"Tee" <th*@streamyx.c om> wrote in message news:eD******** ******@TK2MSFTN GP10.phx.gbl... > Hi, > > How do we increase the size of array on runtime and preserve the previous > data? > I don't want to use ArrayList because the array could be a multi-dimension > array. > > > Thanks, > Tee > >
My mistake, string [] doesn't inherit from System.Array
Try:
public string [] ReDim(string [] array, int newSize)
{
string [] abytNew = new string[newSize];
for(int iCounter = 0; iCounter < array.Length; iCounter++)
abytNew[iCounter] = array[iCounter];
return abytNew;
}
HTH
mooni
"Tee" <th*@streamyx.c om> wrote in message
news:O0******** ******@TK2MSFTN GP14.phx.gbl... It gives error:
An unhandled exception of type 'System.Argumen tException' occurred in WindowsApplicat ion10.exe
Additional information: Object must be an array of primitives.
if I comment out this Buffer.BlockCop y, it will work, but can't preserve the old value.
Thanks.
"mooni" <to*****@hotmai l.com> wrote in message news:41******@d news.tpgi.com.a u... Buffer.BlockCop y also applies to string arrays:
public string [] ReDim(string [] array, int newSize) { string [] astrNew = new string[newSize]; Buffer.BlockCop y(array, 0, astrNew, 0, newSize); return astrNew; }
HTH mooni
"Tee" <th*@streamyx.c om> wrote in message news:%2******** ********@TK2MSF TNGP14.phx.gbl. .. > It will be a string array. > > Thanks, > Tee > > "mooni" <to*****@hotmai l.com> wrote in message > news:41******** @dnews.tpgi.com .au... >> You didn't specify what type of array but for a byte array you could use > the >> following method: >> >> public byte [] ReDim(byte [] array, int newSize) >> >> { >> >> byte [] abytNew = new byte[newSize]; >> >> Buffer.BlockCop y(array, 0, abytNew, 0, newSize); >> >> return abytNew; >> >> } >> >> Buffer.BlockCop y can handle any type inherited from Array: >> >> byte [] >> int [] >> long [] >> >> etc... >> >> >> HTH >> >> "Tee" <th*@streamyx.c om> wrote in message >> news:eD******** ******@TK2MSFTN GP10.phx.gbl... >> > Hi, >> > >> > How do we increase the size of array on runtime and preserve the > previous >> > data? >> > I don't want to use ArrayList because the array could be a > multi-dimension >> > array. >> > >> > >> > Thanks, >> > Tee >> > >> > >> >> > >
I got it to work after I change to Buffer.BlockCop y code to:
System.Array.Co py(array, astrNew, array.Length);
Thanks,
Tee
"Tee" <th*@streamyx.c om> wrote in message
news:O0******** ******@TK2MSFTN GP14.phx.gbl... It gives error:
An unhandled exception of type 'System.Argumen tException' occurred in WindowsApplicat ion10.exe
Additional information: Object must be an array of primitives.
if I comment out this Buffer.BlockCop y, it will work, but can't preserve
the old value.
Thanks.
"mooni" <to*****@hotmai l.com> wrote in message news:41******@d news.tpgi.com.a u... Buffer.BlockCop y also applies to string arrays:
public string [] ReDim(string [] array, int newSize) { string [] astrNew = new string[newSize]; Buffer.BlockCop y(array, 0, astrNew, 0, newSize); return astrNew; }
HTH mooni
"Tee" <th*@streamyx.c om> wrote in message news:%2******** ********@TK2MSF TNGP14.phx.gbl. .. It will be a string array.
Thanks, Tee
"mooni" <to*****@hotmai l.com> wrote in message news:41******** @dnews.tpgi.com .au... > You didn't specify what type of array but for a byte array you could use the > following method: > > public byte [] ReDim(byte [] array, int newSize) > > { > > byte [] abytNew = new byte[newSize]; > > Buffer.BlockCop y(array, 0, abytNew, 0, newSize); > > return abytNew; > > } > > Buffer.BlockCop y can handle any type inherited from Array: > > byte [] > int [] > long [] > > etc... > > > HTH > > "Tee" <th*@streamyx.c om> wrote in message > news:eD******** ******@TK2MSFTN GP10.phx.gbl... > > Hi, > > > > How do we increase the size of array on runtime and preserve the previous > > data? > > I don't want to use ArrayList because the array could be a multi-dimension > > array. > > > > > > Thanks, > > Tee > > > > > >
mooni <to*****@hotmai l.com> wrote: My mistake, string [] doesn't inherit from System.Array
Um, yes it does...
--
Jon Skeet - <sk***@pobox.co m> http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Could you give a broader statement of your original problem? What are
you trying to do? ArrayList is quite capable of supporting
multi-dimensional arrays, but it all depends upon what you want to do
with the arrays and how you want them to work. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jawahar Rajan |
last post by:
All,
I have a datagrid that I use in a ASP.net web page that loads customer data
based on the selected customer ID
Some Customers will have no data in the database (which is oracle 9.2) . So
I check the .HasRows property first then if it is false I skip the data bind
like so
If OraReader.HasRows Then
grdCustomerDetails.AutoGenerateColumns = False
grdCustomerDetails.DataSource = OraReader
|
by: nospam |
last post by:
Hello!
I can pass a "pointer to a double" to a function that accepts
double*, like this:
int func(double* var) {
*var=1.0;
...
}
|
by: Tee |
last post by:
Hi,
Anyone know how to redeclare an array with different size but keep the
previous data? Just like the redim preserve in VB.
Thanks.
|
by: Josef Meile |
last post by:
Hi,
I'm using a ComboBox, some Textboxes, and a DataGrid to represent a
many-to-many relationship between Person and Course. Each time that I change
the value in the ComboBox (which for now is the OID of Person), the
information of the person matching the selected OID is shown in the Textboxes
(Name, Address, id, etc) and the courses this person is taken are shown in a
DataGrid (course name, price, etc.). This is working well so far, I...
|
by: yoshitha |
last post by:
Hi
Can any one tell me how to increase size of an array in C#.net with ASP.Net?
its very urgent for me
thanks
yoshitha
| |
by: partha.p.das |
last post by:
Here is my class:
class MyClass {
public:
MyClass();
~MyClass();
private:
|
by: Bjorn |
last post by:
Hi.
Every time i post data in a form the contents are being checked for
validity.
When i click the back-button, all data is gone and i have to retype it.
It's obvious that only a few or none of the visitors will retype it all
so i'm asking: "how to preserve POST-data when clicking the
back-button?"
i've already tried to print post data as a value in a HTML tag but
|
by: shofu_au |
last post by:
Hi Group,
I am trying to define a class that has a fixed size array of a
structure containing a fixed size array of a structure.
I am using System.Runtime.InteropServices and trying to define the
fixed size using
In the attached console application example when I try to address the
fields in the class I get an execption.
|
by: nagmvs |
last post by:
Hello
I am unable to upload More than 200kb in to my server and also i can downlaod only less than 4MB file from my server .When i am searching in internet i found solution as u can increase size of Metabase.xml (In IIS) file up to 1GB.
Suppose if i increase size of Metabase.xml file up to 200 MB.is there any problems i can face for other applications ?
Why microsoft predefined the size of Metabase.xml file as 4MB ?
...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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: 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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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: 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: 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 we have to send another system
|
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...
| |