I do have a 3-dimensional matrix
private int[][][] Matrix
but I dont know how to fill this. the first dimension is for my slices of a picture the second for my x-values of one slice ad the 3rd slice for my y-values.
so das anybody know how to fill this arrays with some data for testing?
thanks
You can do something like this:
Matrix = new int[5][][]; // 5 slices
Matrix[0] = new int[3][]; // 3 x values for the first slice
Matrix[0][0] = new int[2]; // 2 y values for the first x value in the first slice
But I don't think that you should use something like this. It is very error prone.
I suggest something like this:
class Slice
{
public IList<XValue> XValues {get; set; }
}
class XValue
{
public IList<YValue> YValues {get; set; }
}
class YValue
{
// ...
}
var slices = new List<Slice>();
You can use array literals to create arrays of arrays of arrays:
private int[][][] Matrix = {
{
{1,2,3},
{4,5}
},
{
{1,2},
{3},
{4,5,6,7,8},
{9,10}
},
{
{1,2,3}
}
};
Note that this is a jagged array, so different subarrays can have different number of items. If you want a three dimensional matrix you might want the three dimensional array int[,,]
instead of nested one dimensional arrays.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.