Click to See Complete Forum and Search --> : How to declare a 3d array in a Windows Form Application and compatibility issues


theovaf
July 13th, 2007, 06:38 AM
Dear All,

I'm having problems in declaring a 3d double array in my Form1 class.I want to declare it as a public member but i can't find anywhere how.

What do i write under the
public ref class Form1{

and what at Form1(void){

My second question is about compatibility.I'm programming in vista and VS2005 and i want my windows application to work on XP.does anyone know how?

thanks in advance.

Krishnaa
July 13th, 2007, 08:20 AM
Using array template, here is an example for 2D int array,


array< int^, 2 >^ local = gcnew array< int^, 2 >(ARRAY_SIZE, ARRAY_SIZE);


How to: Create Multidimension Arrays On MSDN (http://msdn2.microsoft.com/en-us/library/2xfh4c7d(VS.80).aspx)

theovaf
July 16th, 2007, 04:27 AM
i am a little bit confused..
i hane declared a 3d array as so:

public ref class Form1 : public System::Windows::Forms::Form
{
public:

array < double^, 3 >^ Ener;

//...
Form1(void)
{
//...
Ener=gcnew array< double^, 3 >(5,5,5);
}

**End**
it compiles fine but when i try to use the array, for example:
Ener[0][1][1]=0;
i get this from the compiler:

error C3915: 'System::Double' has no default indexed property (class indexer)

i am new at this so please help.isn't there a simpler way to declare arrays as in win32 console applications where you would just have to write

double Ener[5][5][5];

Krishnaa
July 16th, 2007, 06:40 AM
i am a little bit confused..
i hane declared a 3d array as so:

public ref class Form1 : public System::Windows::Forms::Form
{
public:

array < double^, 3 >^ Ener;

//...
Form1(void)
{
//...
Ener=gcnew array< double^, 3 >(5,5,5);
}

**End**
it compiles fine but when i try to use the array, for example:
Ener[0][1][1]=0;
i get this from the compiler:

error C3915: 'System::Double' has no default indexed property (class indexer)

i am new at this so please help.isn't there a simpler way to declare arrays as in win32 console applications where you would just have to write

double Ener[5][5][5];

Did you see the example of array on the link I posted last time ???