/// <summary> /// create <see cref="HashSet{T}"/> from <see cref="IEnumerable{T}"/> /// with specified <see cref="IEqualityComparer{T}"/> /// </summary> public static HashSet <T> ToHashSet <T>(this IEnumerable <T> source, IEqualityComparer <T> comparer) { source.ThrowIfArgumentNull(nameof(source)); comparer.ThrowIfArgumentNull(nameof(comparer)); return(new HashSet <T>(source, comparer)); }
/// <summary> /// Returns true if <paramref name="value"/> is in <paramref name="source"/> /// by using a specified <paramref name="comparer"/>. /// </summary> public static bool In <T>(this T value, IEnumerable <T> source, IEqualityComparer <T> comparer) { source.ThrowIfArgumentNull(nameof(source)); comparer.ThrowIfArgumentNull(nameof(comparer)); return(source.Contains(value, comparer)); }