How to compare arrays of string

hi all, I need to compare 2 string arrays and return the string that is not contained in another array, ie I need the excess.
I need something like this:
String1 = {a, b}
String2 = {a}
Result = b
thank you.

Here’s a one-liner that can do that:

result = arr1.Except(arr2).Concat(arr2.Except(arr1)).ToArray

Here is the Stack Overflow thread where it was brought up.

7 Likes

@DanielMitchell Nice One.

1 Like

Hey @GabrielMoreno

You can also Try -

String1.Except(String2).ToArray // Output - b

Regards…!!
Aksh

2 Likes

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.