KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have 2 arrays. I want to convert the index of the first array to the second. Is there a better way to do it than what I have below? Array array1[9]; Array array2[3][3]; // Index is the index of the 1D array public Point convert1Dto2D(int index) { Point p = new Point(); switch (index) { case 0: p.x = 0; p.y = 0; break; case 1: p.x = 0; p.y = 1; break; case 2: p.x = 0; p.y = 2; break; case 3: p.x = 1; p.y = 0; break; case 4: p.x = 1; p.y = 1; break; case 5: p.x = 1; p.y = 2; break; case 6: p.x = 2; p.y = 0; break; case 7: p.x = 2; p.y = 1; break; case 8: p.x = 2; p.y = 2; break; } return p; }
Tags (comma-separated)
Save Edits
Cancel