I have a 3D array that I'm accessing this way Array(int x, int y, int z). What I would like to know, if it is possible to have a struct, that has xyz in it, so that I can use it this way: Array(struct xyz). If it is, then how?
The reason for why I would want this, is that it would be easier for me to read and write, and that it would be alot simpler and less error prone to write. Makes it easier to maintain the bigger picture.
I do know that I could make a class that has its own method, but since I have many classes and applying it to each one would make me quickly loose the readability, using the struct directly would be a better option if available.
Example:
public struct xyz
{
public int x, y, z;
public xyz(int X, int Y, int Z)
{
x = X;
y = Y;
z = Z;
}
}
private void Test()
{
int(,,) Array = new int()
{
{
{0,0},
{0,0},
},
{
{0,0},
{0,0},
}
};
xyz XYZ = new xyz(0,0,0);
Array[XYZ] = 1; // this instead of
Array[XYZ.x, XYZ.y, XYZ.z] = 1 // this
}