add non exist element to ICollection - CSharp System.Collections

CSharp examples for System.Collections:ICollection

Description

add non exist element to ICollection

Demo Code


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

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

Related Tutorials