Hello,
I would suggest that you create a strongly typed collection to help simplify
things.
I would suggest two collections in this case:
InfluenceMatrix and InfluenceCollection
InfluenceMatrix would hold only InfluenceCollection objects
That way, your code would look like this:
private InfluenceMatrix influences=new InfluenceMatrix();
influences[x,y]=GetInfluences() // change GetInfluences to return
InfluenceCollection instead of Influence[]
There are many tools that generate strongly typed collections if you don't
want to write the boilerplate code yourself.
This allows you to separate interface from implementation in this case.
It also simplifies passing the data around in your program.
Finally, the collections themselves can be implemented using arrays so that
you have an O(1) get/set just like an array.
It will also simplify your documentation and make the users of the
collections much happier.
Oscar Papel.
"Kurzweil" <ra******@hotmail.com> wrote in message
news:10***************@newsreader2.wirehub.nl...
I need to make a two dimensional array of objects. These objects are of
type Influence[].
How do I declare such an array?
Now I use:
private object[,] influences;
influences[x, y] = GetInfluences(); // GetInfluences returns type
Influence[]
But when I need to use something from te array I have to typecast from
object to Influence[].
I would like to have a two dimensional array of type Influence[] in stead
of type object.
private Influence[][,] influences; // This does compile
influences[x, y] = GetInfluences(); // Compile error : Wrong number of
indices inside [], expected '1'
Does anyone have an idea?
Thanks in advance,
Kurzweil