本文整理汇总了C#中Data.List.RemoveRange方法的典型用法代码示例。如果您正苦于以下问题:C# List.RemoveRange方法的具体用法?C# List.RemoveRange怎么用?C# List.RemoveRange使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Data.List
的用法示例。
在下文中一共展示了List.RemoveRange方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadActiveJobs
/// <summary>
/// Loads a listing of jobs for the given criteria. Only retrieves jobs that have started and not ended.
/// </summary>
/// <param name="maximumNumberOfJobs">The maximum number of jobs to retrieve, or <c>null</c> for no limit.</param>
/// <param name="limitRandomly">
/// if set to <c>true</c>, retrieves a random segment of the jobs. This only applies when
/// <paramref name="maximumNumberOfJobs"/> is less than the number of jobs retrieved.
/// </param>
/// <param name="onlyHotJobs">if set to <c>true</c> only retrieves jobs marked as hot.</param>
/// <param name="jobGroupId">The job group ID, or <c>null</c> not to restrict the results to a particular job group.</param>
/// <param name="portalId">The portal ID.</param>
/// <returns>A collection of the active jobs meeting the given criteria</returns>
public static ReadOnlyCollection<Job> LoadActiveJobs(int? maximumNumberOfJobs, bool limitRandomly, bool onlyHotJobs, int? jobGroupId, int portalId)
{
var jobs = new List<Job>();
using (IDataReader dr = limitRandomly
? DataProvider.Instance().GetActiveJobs(onlyHotJobs, jobGroupId, portalId)
: DataProvider.Instance().GetActiveJobs(onlyHotJobs, maximumNumberOfJobs, jobGroupId, portalId))
{
while (dr.Read())
{
jobs.Add(FillJob(dr));
}
}
if (maximumNumberOfJobs.HasValue && jobs.Count > maximumNumberOfJobs.Value)
{
if (limitRandomly)
{
Utility.GetRandomSelection(jobs, maximumNumberOfJobs.Value);
}
else
{
jobs.RemoveRange(maximumNumberOfJobs.Value, jobs.Count - maximumNumberOfJobs.Value);
}
}
return jobs.AsReadOnly();
}