UPDATE:
As @Blender pointed out in Python set('aab').issubset(set('abb')) == True. For my situation this needs to return false. The number of each character needs to be taken into account.
Basically I have two strings and I would like to determine if one is a subset of another. Example:
String A: abcd
String B: dbace
String A is a subset of string B
Characters can be in any order and there can be repeating numbers of characters. I had tried ordering the strings and then using String.StartsWith, but this does not work in certain situations. Example:
String A: abcdd
string B: abbcdd
Ordering these and using StartsWith returns false because string B has two "b"s
I did some looking around and found Python’s issubset method which appears to do what I want, so I’m curious if anyone has come across its equivalent in .NET (or an effective method someone has come up with on their own).
NOTE: I am looking for subsets, not anagrams.
There’s nothing built-in that I know of that behaves as you want it. Strictly speaking, this isn’t a real subset as it should be doing set comparisons as it is in Python (where every item in a set is unique) but it should be simple to cook one up.
If you want true set mechanics, it is just as simple.