+ 1

How do I check if two labels contain the same letters?

I need a way to check if two labels contain the same letters, though they don't need to be exactly in the same order. For example: Label1 ==''abcde'' Label2==''abdec'' I then would like them to give me the same value, so it doesn't matter in what order the input is, as long as it contains the same letters/numbers.

24th Oct 2018, 10:28 PM
Samuel
Samuel - avatar
3 Respuestas
+ 1
Thanks for making that, though it's not exactly what I needed. I've found out what my code missed and will edit my post later with the right code. Cheers!
25th Oct 2018, 11:30 PM
Samuel
Samuel - avatar
25th Oct 2018, 9:31 PM
sneeze
sneeze - avatar
0
if (Label1 .All(val => Label2.Contains(val)) && Label2.All(val => Label1 .Contains(val))) if Label1 has all of the letters that Label2 has, it's true, AND, if Label2 has all of the letters that Label1 has, it's true! If either of them contain any different ones from each other, it will return false. Examples of this are: Label1: "abcdef" Label2: "cdfbae" = True Label1: "abcde" Label2: "cdbaef" = False
11th Jan 2019, 7:11 PM
Joshua Cade Barber
Joshua Cade Barber - avatar