本文整理汇总了C#中Data.List.Count方法的典型用法代码示例。如果您正苦于以下问题:C# List.Count方法的具体用法?C# List.Count怎么用?C# List.Count使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Data.List
的用法示例。
在下文中一共展示了List.Count方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanCreateAt
/// <summary>
/// Determines whether an <see cref="Appointment"/> can be created at the specified <paramref name="start"/> time until the specified <paramref name="end"/> time.
/// </summary>
/// <param name="moduleId">The ID of the module in which the appointment is to be created.</param>
/// <param name="start">The start of the new <see cref="Appointment"/>.</param>
/// <param name="end">The end of the new <see cref="Appointment"/>.</param>
/// <param name="max">The maximum appointments allowed for the specified time range</param>
/// <returns>
/// <c>true</c> if an <see cref="Appointment"/> can be created at the specified <paramref name="start"/> time until the specified <paramref name="end"/> time; otherwise, <c>false</c>.
/// </returns>
public static bool CanCreateAt(int moduleId, DateTime start, DateTime end, int? max)
{
var appointments = AppointmentSqlDataProvider.GetConcurrentAppointments(moduleId, start, end);
var appointmentsInRange = new List<Appointment>(max ?? 10);
while (appointments.Read())
{
appointmentsInRange.Add(Fill(appointments));
}
var uniqueStartTimes = appointmentsInRange.Select(apt => apt.StartDateTime).Distinct();
return uniqueStartTimes.All(time => max > appointmentsInRange.Count(apt => time >= apt.StartDateTime && time < apt.EndDateTime));
}
示例2: HitsReceived
public int HitsReceived(Entity target, Entity source, bool timed)
{
var sourceString = source?.Id.ToString() ?? "";
var key = "hits_received/" + target + "/" + sourceString + "/" + timed;
if (_caching.ContainsKey(key)) return (int) _caching[key];
IEnumerable<Skill> result= new List<Skill>();
if (TargetSourceSkill.ContainsKey(target))
{
if (!timed && source != null)
{
if (TargetSourceSkill[target].ContainsKey(source))
{
result = from skills in TargetSourceSkill[target][source]
where skills.Type == Database.Type.Damage
select skills;
}
}
else
{
result = from skills in TargetSourceSkill[target].Values
from skill in skills
where skill.Type == Database.Type.Damage
select skill;
}
}
var count = result.Count();
_caching.Add(key, count);
return count;
}