Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Multi-dimensional arrays
Message
From
14/07/2002 17:24:20
 
 
To
14/07/2002 12:06:21
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00678465
Message ID:
00678526
Views:
18
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
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform