Remove values from the list starting at the index start. - CSharp System.Collections.Generic

CSharp examples for System.Collections.Generic:List

Description

Remove values from the list starting at the index start.

Demo Code

// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
using System.Linq;
using System.Diagnostics.Contracts;
using System.Collections.ObjectModel;
using System.Collections.Generic;
using System;/*from   www.  j  a  v a 2  s  . c  o  m*/

public class Main{
        /// <summary>
        /// Remove values from the list starting at the index start.
        /// </summary>
        public static void RemoveFrom<T>(this List<T> list, int start)
        {
            Contract.Assert(list != null);
            Contract.Assert(start >= 0 && start <= list.Count);

            list.RemoveRange(start, list.Count - start);
        }
}

Related Tutorials