P
pengbsam
Hello All:
Having a problem with arraylist.copyto function. And here's a
sample of my code in C#:
In global-->
public struct point
{
int x;
string y;
}
static public point point;
static public point pointarray[];
static public Arraylist myal = new Arraylist();
in sub_function -->
for (i=0; i< some limites; i++)
{
global.point.x = some limites.some value;
global.point.y = some limites.some string;
global.myal.Add(global.point);
}
in Main function -->
int a;
string b;
global.pointarray = new global.point[global.myal.Count];
global.myal.Copyto(pointarray);
for (i=0; i<global.myal.count; i++)
{
a = pointarray.x;
b = pointarray.y;
}
global.myal.Clear();
pointarray = null;
This is basically the logic of the steps that I am trying to make a
dynamic array struct, of course I understand there are different ways
of doing this, but this one seems easiest if I was to pick and choose
what needed to be inserted into my arraylist in main / sub function. It
works fine on my computer (xp pro .net 2.0), however it doesn't work on
my company's server computer (running server2003.net 2.0) Saying there
there is a casting exception on the global.myal.Copyto(pointarray)
statement. I spend a lot of time trying to understand why this differ
from machine to machine. But came up with nothing in MSDN or other
resources. Have anyone done something like this? Please let me know!!
Thank You!
Also, it keep on telling me that I have a casting problem, so I tried
to explicitly cast the array out of arraylist instead of copyto()..
Doesn't work either. Any ideas how to do that? Very much appreciated
it!!
Having a problem with arraylist.copyto function. And here's a
sample of my code in C#:
In global-->
public struct point
{
int x;
string y;
}
static public point point;
static public point pointarray[];
static public Arraylist myal = new Arraylist();
in sub_function -->
for (i=0; i< some limites; i++)
{
global.point.x = some limites.some value;
global.point.y = some limites.some string;
global.myal.Add(global.point);
}
in Main function -->
int a;
string b;
global.pointarray = new global.point[global.myal.Count];
global.myal.Copyto(pointarray);
for (i=0; i<global.myal.count; i++)
{
a = pointarray.x;
b = pointarray.y;
}
global.myal.Clear();
pointarray = null;
This is basically the logic of the steps that I am trying to make a
dynamic array struct, of course I understand there are different ways
of doing this, but this one seems easiest if I was to pick and choose
what needed to be inserted into my arraylist in main / sub function. It
works fine on my computer (xp pro .net 2.0), however it doesn't work on
my company's server computer (running server2003.net 2.0) Saying there
there is a casting exception on the global.myal.Copyto(pointarray)
statement. I spend a lot of time trying to understand why this differ
from machine to machine. But came up with nothing in MSDN or other
resources. Have anyone done something like this? Please let me know!!
Thank You!
Also, it keep on telling me that I have a casting problem, so I tried
to explicitly cast the array out of arraylist instead of copyto()..
Doesn't work either. Any ideas how to do that? Very much appreciated
it!!