473,407 Members | 2,326 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,407 software developers and data experts.

Struct Array, Arraylist.Copyto() (InvalidCastException)

Hello All:
Having a problem with arraylist.copyto function. And here's a
sample of my code:
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[i].x = some limites.some value;
global.point[i].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[i].x;
b = pointarray[i].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!!

Aug 29 '06 #1
2 3552
Can Any one Help???

Aug 30 '06 #2
<pe******@yahoo.comwrote:
Can Any one Help???
I'm sure they can, but you'll need to be more patient. Things are also
likely to be faster if you post a short but complete program
demonstrating your problem instead of just snippets.

See http://www.pobox.com/~skeet/csharp/complete.html for details.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Aug 30 '06 #3

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

Similar topics

6
by: reb | last post by:
Hi, How do i increase the size of the array without losing the data of that array in c#? thanks
4
by: David Rogers | last post by:
Is this sequence about as efficient as I can get for sometimes expanding an array? MyClass MyFunc() { MyClass result = new MyClass ; { // Do stuff that might possibly allocate an array...
9
by: Haobin | last post by:
Hi everyone, I have an ArrayList whose members are classes. These classes are derived from a same base class. The base class has a floating point array and a string. How do I access each element in...
8
by: Sorin Sandu | last post by:
Is it posible to modify the lenghth of an array ? I want to do something like int i = 0; string debit = new string; string credit = new string; while (myread3.Read())
1
by: Craig | last post by:
Hey Everyone - I'm trying to determine the fastest way of moving array information around and could use some help. Here's the setup: Class A stores a DateTime and an amount (a payment)....
5
by: hazz | last post by:
If this makes sense, I would like to convert an arraylist of objects returned from foo() into an array of the objects themselves per; private Customer customers; private int idx = 0; public...
2
by: Russ Green | last post by:
I am currently working on a small VB.NET utility that accesses the Microstation VBA object model via COM. I have this code which I am trying to get to work... The key bits of information are ...
3
by: Stephen Travis | last post by:
I'm trying to write a subroutine that will fill an array of some type with several objects of that type. The subroutine works fine if I directly reference the array but if I pass the array as an...
0
by: fmlamela | last post by:
Hi, I have to create a bi-dimensional matrix, where each row is a int array of a specific size. For adding a new row, I use the ArrayList.Add (int ) command. I would like now to convert this...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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
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...

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.