sub List from to - CSharp System.Collections.Generic

CSharp examples for System.Collections.Generic:List

Description

sub List from to

Demo Code


using System.Collections;
using System;/* w  ww  . ja  va  2  s .com*/

public class Main{
    public static IList subList(IList list, int from, int to)
      {
         IList newList = new ArrayList();
         for (int i = from; i < to; i++)
            newList.Add(list[i]);
         return newList;
      }
    public static bool add(ICollection list, object value)
      {
         if (!((IList) list).Contains(value))
         {
            ((IList) list).Add(value);
            return true;
         }
         else
            return false;
      }
}

Related Tutorials