本文整理汇总了C#中ISet.Intersect方法的典型用法代码示例。如果您正苦于以下问题:C# ISet.Intersect方法的具体用法?C# ISet.Intersect怎么用?C# ISet.Intersect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ISet
的用法示例。
在下文中一共展示了ISet.Intersect方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Negotiate
public string Negotiate(ISet<string> server, ISet<string> client)
{
if (!server.Any() || !client.Any())
return null;
var matches = client.Intersect(server);
if (!matches.Any())
throw new SubProtocolNegotiationFailureException("Unable to negotiate a subprotocol");
return matches.First();
}
示例2: Intersect
/// <summary>
/// Performs an "intersection" of the two sets, where only the elements
/// that are present in both sets remain. That is, the element is included only if it exists in
/// both <c>a</c> and <c>b</c>. Neither input object is modified by the operation.
/// The result object is a <c>Clone()</c> of one of the input objects (<c>a</c> if it is not <c>null</c>) containing the
/// elements from the intersect operation.
/// </summary>
/// <param name="a">The left hand side set of elements to intersect.</param>
/// <param name="b">The right hand side set of elements to intersect.</param>
/// <returns>The intersection of the two input sets. <c>null</c> if both sets are <c>null</c>.</returns>
public static ISet Intersect(ISet a, ISet b)
{
if (a == null && b == null)
return null;
return a == null ? b.Intersect(a) : a.Intersect(b);
}
示例3: Intersect
/// <summary>
/// Performs an "intersection" of the two sets, where only the elements
/// that are present in both sets remain. That is, the element is included only if it exists in
/// both <c>a</c> and <c>b</c>. Neither input object is modified by the operation.
/// The result object is a <c>Clone()</c> of one of the input objects (<c>a</c> if it is not <see langword="null" />) containing the
/// elements from the intersect operation.
/// </summary>
/// <param name="a">A set of elements.</param>
/// <param name="b">A set of elements.</param>
/// <returns>The intersection of the two input sets. <see langword="null" /> if both sets are <see langword="null" />.</returns>
public static ISet Intersect(ISet a, ISet b)
{
if (a == null && b == null)
return null;
else if (a == null)
{
return b.Intersect(a);
}
else
return a.Intersect(b);
}
示例4: Intersect
/// <summary>
/// Performs an "intersection" of the two sets, where only the elements
/// that are present in both sets remain.
/// </summary>
/// <remarks>
/// <p>
/// That is, the element is included only if it exists in both
/// <paramref name="setOne"/> and <paramref name="anotherSet"/>. Neither input
/// object is modified by the operation. The result object is a
/// <b>clone</b> of one of the input objects (<paramref name="setOne"/>
/// if it is not <see langword="null"/>) containing the elements from
/// the intersect operation.
/// </p>
/// </remarks>
/// <param name="setOne">A set of elements.</param>
/// <param name="anotherSet">A set of elements.</param>
/// <returns>
/// The intersection of the two input sets; <see langword="null"/> if
/// both sets are <see langword="null"/>.
/// </returns>
public static ISet Intersect(ISet setOne, ISet anotherSet)
{
if (setOne == null && anotherSet == null)
{
return null;
}
else if (setOne == null)
{
return anotherSet.Intersect(setOne);
}
else
{
return setOne.Intersect(anotherSet);
}
}
示例5: Intersect
public static ISet Intersect(ISet s1, ISet s2)
{
return s1.Intersect(s2);
}