MSDN documentation of both methods looks very similar. Also the example cited beneath the remarks for IsSupersetOf
is not very helpful either.
Can someone please explain to me the difference using simple language?
MSDN documentation of both methods looks very similar. Also the example cited beneath the remarks for IsSupersetOf
is not very helpful either.
Can someone please explain to me the difference using simple language?
You can think of it like the difference between >
and >=
. IsSuperSetOf is doing something like >=
, so your set could have exactly the same elements that are in the set you're comparing to. By contrast, a proper super set is kind of like >
and has extra elements that the second set doesn't have.
For example, a set is a superset of itself, but it's not a proper superset of itself.
A superset of set A
is a set that contains all of the elements of set A
A proper superset of A
is a set that contains all of the elements of A
but is not equal to A
.
So if A
= {1,2,3}
, then {1,2,3}
is a superset of A
but not a proper superset, while {1,2,3,4}
is a proper superset.
A proper subset cannot equal the set.
{1,2,3} is a subset of {1,2,3}, but not a proper subset
{1,2} is a proper subset (and subset) of {1,2,3}
The answer is in the mathematical definitions underneath:
If A and B are sets and every element of A is also an element of B, then:
If A is a subset of B, but A is not equal to B (i.e. there exists at least one element of B which is not an element of A), then
Source: Wikipedia