I'm working on a game where I want to check if the characters of a string are contained in another string. Obviously a set would be my first choice but I want to account for duplicates. For example:
"met".IsContainedWithin("meet"); => true
"meet".IsContainedWithin("met"); => false
A multi-set would be nice but it sounds like C# doesn't have anything like that. I could just do it iteratively but I was wondering if there was a simpler way (with LINQ perhaps). Thanks!
EDIT:
I wasn't so clear. I want it to return true regardless of the order of the letters:
"git".IsContainedWithin("light")=> true
"pall".IsContainedWithin("lamp")=> false
This works for me:
I tested it like this:
I got these results: