Perplex Posted July 18, 2016 Posted July 18, 2016 (edited) 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, 2016 by Perplex
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now