Search code examples
c#windows-8windows-store-apps

what is the replacement of c# CollectionBase in windows 8 Store Apps?


I'm Navigating a Class from windows Forms app to windows store app. The Class i've got from internet is shown below,

    public class ElementList : CollectionBase
{
    /// <summary>
    /// A Collection of Element Nodes
    /// </summary>      
    public ElementList() 
    {           
    }

    public void Add(Node e) 
    {
        // can't add a empty node, so return immediately
        // Some people tried dthis which caused an error
        if (e == null)
            return;

        this.List.Add(e);
    }

    // Method implementation from the CollectionBase class
    public void Remove(int index)
    {
        if (index > Count - 1 || index < 0) 
        {
            // Handle the error that occurs if the valid page index is       
            // not supplied.    
            // This exception will be written to the calling function             
            throw new Exception("Index out of bounds");            
        }        
        List.RemoveAt(index);           
    }

    public void Remove(Element e)
    {           
        List.Remove(e);         
    }

    public Element Item(int index) 
    {
        return (Element) this.List[index];
    }


}

In the above class the CollectionBase is not accepted in the store app. Please tell me a way to navigate this to windows 8 store app. . .

Thanks in Advance!


Solution

  • you don't need to use

        IList 
    

    instead you can use

        List<Object>. . .
    

    Just give it a try. . .

    It worked for me May be it works for you too..