0

I want to reverse some chars but I get the following error:

Cannot implicitly convert type 'System.Collections.Generic.IEnumerable<int[]>' to 'int[][]'.

Below is code for reference.

private void tp(int[][] cd = null,int offset = 0)
    {
        if (cd == null) return;
        cd = cd.Reverse();
        /*rest of code...*/
    }
Chris
  • 27,210
  • 6
  • 71
  • 92
  • @JohnWu: Your comment is absolutely not right. Your comment might be right for `int[,]` (I've not checked) but it is certainly not true for `int[][]` as can be simply tested. – Chris Jan 31 '19 at 00:10
  • I've added the c# tag to the question since your code looks like that's the language you are using. Language tags are helpful to make sure the right people look at your question! – Chris Jan 31 '19 at 00:17

1 Answers1

0

Reverse will return an IEnumerable<T>, in this case an IEnumerable<int[]> as the error message suggests. To get to an int[][] all you need to do is call ToArray() on the result of the reverse. That is:

cd = cd.Reverse().ToArray();
Chris
  • 27,210
  • 6
  • 71
  • 92