I have an array of which I would like to get the length of each dimension stored in an array. I.e. I would like something like the following:
Array myArray = //...Blah blah myArray is defined somewhere in code
int[] dimLengths = myArray.SomeLinqStatement...
I can do this with some for loop(s) but I was hoping there would be a simple linq statement. So for example, if myArray is a 3D array of 2x3x4 I want dimLengths to be {2, 3, 4}.
You don’t need LINQ. Here is a simple solution:
If you must use LINQ, you could try this, though I am sure the other way is better: