0

So I have 2 sets of string[9,9] arrays, and I would like to compare them, but array1.Cast<string>.SequenceEqual(array2.Cast<string>); gives me an error under the .Cast<string> saying it's a method, which is not valid in the given context.

is there any better way to compare two multidimensional arrays of strings?

Tanruss1
  • 1
  • 1
  • 1
    It should be `.Cast()`, not `.Cast`. In both places – Rob Dec 02 '15 at 02:55
  • I input both of them to be the same, but for whatever reason, it still came out false – Tanruss1 Dec 02 '15 at 02:59
  • 1
    Please post an [MCVE](http://stackoverflow.com/help/mcve). – Jonathon Reinhart Dec 02 '15 at 03:00
  • if youve done what Rob commented and you still have problem in results then you have to show how you populate those arrays with an example. – M.kazem Akhgary Dec 02 '15 at 03:03
  • 1
    @Rob Linq methods do not work on 2d+ arrays at all. – Alexei Levenkov Dec 02 '15 at 03:21
  • @AlexeiLevenkov Actually, `.Cast()` does infact work on multi-dimensional arrays.. try it :) – Rob Dec 02 '15 at 03:28
  • @Rob you indeed right - `Cast` works on `IEnumerable` (unlike other methods that expect `IEnumerable`)... But that would not be really good comparison of arrays as it will ignore dimensions - 3x4 would be the same as 4x3 or 2x2x3... Otherwise `(new int[3,4]).Cast().SequenceEqual((new int[4,3]).Cast())` compiles/returns true. – Alexei Levenkov Dec 02 '15 at 03:34

0 Answers0