Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I would like to initialize this variable, but I don't know how:

double[][,] globe1 = new double[3] [100,100] ; //does not work.

What I have tried:

theoretically, I would like to have something like this:
globe1[lat, long] = [3.0,6.4,7,] //as an example of one element of this array
Posted
Updated 22-Oct-21 6:16am

see if this helps:
double[][,] glbl = new double[3][,];

double[,] temp = new double[3, 3];

double id = 0.05d; // use 0.05d so we can verify doubles are being assigned

for (int i = 0; i < 3; i++)
{
    for (int j = 0; j < 3; j++)
    {
        for (int k = 0; k < 3; k++)
        {
            temp[j,k] = id++;
        }
    }

    glbl[i] = temp;

    // put a break-point here and inspect glbl

    temp = new double[3, 3]; // must re-initialize 'temp
}
Assuming you might want to associate a name (string) with your geo-data: consider using a Class or Struct (or Tuple).
 
Share this answer
 
v4
Thank you very much for your answer.
IN fact what I was searching for is something like this:

public void fill_Vector_object()
{
double[,][] glbl = new double[3,3][];

for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
glbl[i, j] = new double[3] { 0.0, 0.0, 0.0 };
}

}
}
Where I can make a correspondence of [Latitude, Longitude] {to X,Y,Z}. This works fine
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900