Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Multi-dimensional arrays
Message
De
14/07/2002 17:24:20
 
 
À
14/07/2002 12:06:21
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00678465
Message ID:
00678526
Vues:
19
This message has been marked as the solution to the initial question of the thread.
>I haven't worked with arrays yet, so I'm not familiar with the syntax. I was wondering if this can be defined differently. Like in VFP, where you define the array first, then fill it. Something like this maybe? It would definitely be more readable if you could ...
>
>object[,] oArray = new object(something here?);
>oArray[1,1] = 4
>oArray[1,2] = "Claudio";
>
>etc.
>
well, I went for this sort of way... the more close I can come for VFP is this:
object[,] persons = new object(4,2)

persons[0,0] = 25;
persons[0,1] = "John";
persons[1,0] = 30;
persons[1,1] = "Paul";
persons[2,0] = 50;
persons[2,1] = "Mark";
persons[3,0] = 10;
persons[3,1] = "Matt";

Console.Write( persons[1,0] + " " + persons[1,1] )
But we can do this (a little bit different from what Gérald has shown first):
// Instead of assigning the values by columns, I assign by rows)

object[,] persons = {{25,"John"},{30,"Paul"},{50,"Mark"},{10,"Matt"}}
Or, I think this one is a little more cleaner and readable:
object[,] persons = {{25,"John"},
                     {30,"Paul"},
                     {50,"Mark"},
                     {10,"Matt"}}
So, we can access an element just like in VFP. Anyway, if decided to go for the methods to "set" and "get" values, I saw that there´s already native methods for that: SetValue and GetValue (still didn´t study a lot on this...)
Claudio Lassala
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform