Skip to content

Conversation

@puniththota
Copy link
Collaborator

Array extension method to convert multi-dimensional array to jagged array. Tests added.

@puniththota puniththota linked an issue Jul 17, 2020 that may be closed by this pull request
Copy link
Owner

@ColmBhandal ColmBhandal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ConvertToJaggedArray<T>(this T[,] multiDimensionalArray) - rename the parameter to twoDimensionalArray (or just array) and put the entire function into the class ArrayExtension2D.

The test should also go into the 2D array extension test.

Add to documentation of ConvertToJaggedArray that the jagged array's indices always start at zero. If the lower bounds of the multidimensional array are non-zero, a number of blank entries will be inserted into the jagged array such that the indices of elements in the jagged array match those in the original array.

See if you can reduce the for loops in Given_MultiDimensionalArray_When_ConvertedToJaggedArray_Then_CorrectValueReturned so that you can just use Assert on arrays (you may still need one for loop to iterate through the outer dimension)

Convert Given_MultiDimensionalArray_When_ConvertedToJaggedArray_Then_CorrectValueReturned to a parametrised test - see other tests for examples.

Copy link
Owner

@ColmBhandal ColmBhandal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See inline comments

@puniththota puniththota merged commit a32e782 into develop Jul 17, 2020
@puniththota puniththota deleted the MultiDimensionalArrayToJaggedArray branch July 17, 2020 16:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Convert multi-dimension array to jagged array

3 participants