当前位置: 首页>>代码示例>>C#>>正文


C# List.RemoveRange方法代码示例

本文整理汇总了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();
        }
开发者ID:fujinguyen,项目名称:Engage-Employment,代码行数:39,代码来源:Job.cs


注:本文中的Data.List.RemoveRange方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。