이 코드는 다음과 같은 오류를 표시합니다. "암시 적으로 ArrayList [] 유형을 ArrayList [] []"로 변환 할 수 없습니다.이 행의 경우 : m_grid[gridIndexX] = new ArrayList[Height];
어떻게 할 수 있습니까? 또 다른 방법? m_grid 배열이 2 차원 배열 일 때 작동하지만 3 차원 배열로 작동하지 않습니다. 도움을 청합니다.암시 적으로 ArrayList []를 ArrayList [] []로 변환 할 수 없습니다.
private ArrayList[][][] m_grid;
private void initialize() {
Width = 5;
Height = 5;
Depth = 5;
m_grid = new ArrayList[Width][][];
}
public void Refresh(ref ArrayList particles) {
m_grid = null;
m_grid = new ArrayList[Width][][];
if (particles != null) {
for (int i = 0; i < particles.Count; i++) {
FluidParticle p = (FluidParticle) particles[i];
int gridIndexX = GetGridIndexX(ref p);
int gridIndexY = GetGridIndexY(ref p);
int gridIndexZ = GetGridIndexZ(ref p);
// Add particle to list
if (m_grid[gridIndexX] == null) {
m_grid[gridIndexX] = new ArrayList[Height];
}
if (m_grid[gridIndexX][gridIndexY][gridIndexZ] == null) {
m_grid[gridIndexX][gridIndexY][gridIndexZ] = new ArrayList();
}
m_grid[gridIndexX][gridIndexY][gridIndexZ].Add(i);
}
}
}
3 차원 ArrayList와 같은 것은 없습니다. 당신이 가지고있는 것은 ArrayLists의 3 차원 ** 배열입니다 ** ... – Adam
아마도 하나의리스트를 가질 수있는 클래스를 정의하는 것이 좋습니다.? –
Bazzz
예 실제로 그것을 의미하고 싶었습니다. @codeparkle – Ozg