Posted July 18, 20169 yr The correct approach convert 1D List to 2D List (Randomly)? Please look at the my approach is correct ? List<Tuple<object, object, object>> OneDimensionalLists = new List<Tuple<object, object, object>>(); List<List<Tuple<object, object, object>>> TwoDimensionalLists = new List<List<Tuple<object, object, object>>>(); int i1 = 0; for (int i = 0; i < OneDimensionalLists.Count; i++) { TwoDimensionalLists.Add(new List<Tuple<object, object, object>>()); var random = new Random(seed); int next = random.Next(10, 30); for (int j = 0; j < next; j++) { if (OneDimensionalLists.Count == i1) goto go; TwoDimensionalLists[i].Add(OneDimensionalLists[i1++]); } } go: Edited July 18, 20169 yr by Perplex
Create an account or sign in to comment