A Collection of Objects (ArrayList, Hashtable, etc)

    Date: 06/20/06 (C Sharp)    Keywords: no keywords

    Hello,

    I'm trying to create a hashtable or arraylist of objects of classes, which I wrote myself earlier.

    so I have:

    class myClass
    {
    myClass()
    {
    //blah
    }

    myMethod()
    {
    //stuff
    }
    }

    myClass myClassInstance = new myClassInstance;
    ArrayList list = new ArrayList();

    list.Add(myClassInstance);

    // So here I'm trying to run a method from the list.

    list[0].myMethod();


    Here, I get an error, that an Object class does not have "myMethod". So, C# doesn't recognize that it's not an Object in the list, it's MyClass. How can I make a collection of my own objects, so that I can use their methods like that? Sounds like it has something to do with the rules of polymorphism in C#, which I don't know, as I'm used to template system of C++.

    Thanks.

    Source: http://community.livejournal.com/csharp/66322.html

« longshot || C# program with memory issues »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home