V
Vaden95
I am trying to uae ArrayList to store arrays of structures, but I can't get my
data back after storing the arrays.
My (highly shrunk and modified) code is below. The problem is at the line
labled Line 1. I get an exception thrown saying:
"An unhandled exception of type 'System.InvalidCastException' occurred in
SLAP.exe
Additional information: Specified cast is not valid."
I have a watch at line 1 for al, and before the line is run, al is correctly
populated and shows the list of arrays of type A.
What is the problem, and how do you fix it. Any help would be most helpful.
By the way, I am new to VisualC++.NET, and I am trying to learn it by redoing
program that I have written in VC++.
Chuck Gantz
First, I have a structure
__gc struct A
{
public:
double a, b;
A(double ain, double bin)
: a(ain), b(bin){};
};
Then I have my main class that has an ArrayList
__gc class B
{
private:
//Only allow one copy of al to exist
static ArrayList* al;
public:
B()
{
al= new ArrayList();
ReadData();
A* llp = __try_cast<A*>(al->Item[2]); //Line 1- gives Exception
}
void ReadData()
{
data back after storing the arrays.
My (highly shrunk and modified) code is below. The problem is at the line
labled Line 1. I get an exception thrown saying:
"An unhandled exception of type 'System.InvalidCastException' occurred in
SLAP.exe
Additional information: Specified cast is not valid."
I have a watch at line 1 for al, and before the line is run, al is correctly
populated and shows the list of arrays of type A.
What is the problem, and how do you fix it. Any help would be most helpful.
By the way, I am new to VisualC++.NET, and I am trying to learn it by redoing
program that I have written in VC++.
Chuck Gantz
First, I have a structure
__gc struct A
{
public:
double a, b;
A(double ain, double bin)
: a(ain), b(bin){};
};
Then I have my main class that has an ArrayList
__gc class B
{
private:
//Only allow one copy of al to exist
static ArrayList* al;
public:
B()
{
al= new ArrayList();
ReadData();
A* llp = __try_cast<A*>(al->Item[2]); //Line 1- gives Exception
}
void ReadData()
{