singleton List - CSharp System.Collections.Generic

CSharp examples for System.Collections.Generic:List

Description

singleton List

Demo Code


using System.Collections;
using System;/* w  w w . j a v a2 s .co  m*/

public class Main{
    public static IList singletonList(object obj)
      {
         IList list = new ArrayList();
         list.Add(obj);
         return list;
      }
    public static bool add(ICollection list, object value)
      {
         if (!((IList) list).Contains(value))
         {
            ((IList) list).Add(value);
            return true;
         }
         else
            return false;
      }
}

Related Tutorials