I have a 3 dimensional char array initialized as such:
char[,,] cube = new char[10, 10, 10];
It's completely filled and I want to convert its contents to a single string. My current method is this:
for (int z = 0; z < 10; z++) {
for (int y = 0; y < 10; y++) {
for (int x = 0; x < 10; x++) {
build += cube[z, y, x];
}
}
}
Attempting to do build = new string(cube)
gives an error:
cannot convert from 'char[*,*,*]' to 'char*'
The for
loops are incredibly fast, completing in less than a millisecond on my setup (from 1500 to 4000 ticks). Wondering if a single line method exists that will accomplish the same thing that these nested for
loops are doing?
EDIT:
This code will only be used once in the entire program, so I don't need something reusable.