本文整理汇总了C#中ReadOnlyCollection.Count方法的典型用法代码示例。如果您正苦于以下问题:C# ReadOnlyCollection.Count方法的具体用法?C# ReadOnlyCollection.Count怎么用?C# ReadOnlyCollection.Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ReadOnlyCollection
的用法示例。
在下文中一共展示了ReadOnlyCollection.Count方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PatternMatchRuleProcessor
private PatternMatchRuleProcessor(ReadOnlyCollection<PatternMatchRule> rules)
{
Debug.Assert(rules.Count() != 0, "At least one PatternMatchRule is required");
Debug.Assert(rules.Where(r => r == null).Count() == 0, "Individual PatternMatchRules must not be null");
ruleSet = rules;
}
示例2: GetHandValue
/// <summary>
/// Gets the value of a hand and whether it is soft or not
/// </summary>
/// <param name="hand">The hand to evaluate</param>
/// <param name="soft">[OUT] Is the hand's value soft?</param>
/// <returns>The value of the specified hand</returns>
public static int GetHandValue(ReadOnlyCollection<Card> hand, out bool soft)
{
int total = 0;
foreach (Card c in hand)
{
total += s_cardValues[c.Value];
}
int aceCount = hand.Count(c => c.Value == CardName.Ace);
while (total > 21 && aceCount > 0)
{
total -= 10;
aceCount--;
}
soft = aceCount > 0;
return total;
}
示例3: PickBestMatch
private static BindContext PickBestMatch(ReadOnlyCollection<BindContext> results)
{
// also pick not authenticated since subsequent reauthentication might lead to success
var wannabes = results.Where(r => r.Result == BindResult.Success || r.Result == BindResult.NotAuthenticated).ToList();
var dirty = true;
while (dirty && results.Count() > 1)
{
var pairs = wannabes.SelectMany(r1 => wannabes.Select(r2 => Tuple.Create(r1, r2)));
var resolvableConflict = pairs.FirstOrDefault(p =>
{
var rp_prefix = p.Item1.ResourceTemplate.IndexOf("{") == -1 ? p.Item1.ResourceTemplate :
p.Item1.ResourceTemplate.Substring(0, p.Item1.ResourceTemplate.IndexOf("{"));
var rc_prefix = p.Item2.ResourceTemplate.IndexOf("{") == -1 ? p.Item2.ResourceTemplate :
p.Item2.ResourceTemplate.Substring(0, p.Item2.ResourceTemplate.IndexOf("{"));
return p.Item1 != p.Item2 && (rp_prefix.IsEmpty() || rc_prefix.StartsWith(rp_prefix));
});
if (resolvableConflict != null)
{
wannabes.Remove(resolvableConflict.Item1);
dirty = true;
}
else
{
dirty = false;
}
}
return wannabes.Count() == 1 ? wannabes.Single() : null;
}