Object unknown
-
Is there a way I can use an object without knowing which object it realy is? for exemple: I have several objects that implement IEnumerable(these objects has arrayList), I need to Implement IEnumerator and I want to do it once. but I don't know for which object I implement it for so when I do : object.arrayList[i] -its an error. (object doen't have an arrayList property). how can I do it??? thanks in advance , sharon
-
Is there a way I can use an object without knowing which object it realy is? for exemple: I have several objects that implement IEnumerable(these objects has arrayList), I need to Implement IEnumerator and I want to do it once. but I don't know for which object I implement it for so when I do : object.arrayList[i] -its an error. (object doen't have an arrayList property). how can I do it??? thanks in advance , sharon
Ahhh, the beauty of programming via interfaces :) [contractual I think is the term]
IEnumerable ie = myobject as IEnumerable
if( ie != null )
{
// myobject implements IEnumerable so do something with it
IEnumerator = ie.GetEnumerator();
...
}HTH, James Simplicity Rules!