hey all,
i created and implemented an interface called IAnimal.
inside my code when i instantiate an animal object:
dim _animal as IAnimal
_animal = new Dog()
i assumed i would be able to do something like this:
_animal.GetType()
and it would tell me it was a dog type.
do i have to code that myself? how would you do that?
thanks,
rodchar
bruce barker - 10 Jul 2007 22:17 GMT
as animal is declared as an IAnimal, thats its type.
you want GetTypes() which will return an array of types implemented by
the object that animal references. you can scan the array for class
types, and get the base or supertype. (hint: each type has a basetype
property)
-- bruce (sqlwork.com)
> hey all,
> i created and implemented an interface called IAnimal.
[quoted text clipped - 12 lines]
> thanks,
> rodchar
rodchar - 10 Jul 2007 22:58 GMT
is GetTypes() supposed to show up in code complete? _animal.GetTypes()
because when i use the dot operator there's only my property and my method
that shows up nothing else. i apologize if i missing the mark.
> as animal is declared as an IAnimal, thats its type.
>
[quoted text clipped - 21 lines]
> > thanks,
> > rodchar
Patrice - 11 Jul 2007 10:58 GMT
Use CType(_animal, Object).GetType.ToString()
As _animal is an interface you see only what is related to this interface.
--
Patrice
> hey all,
> i created and implemented an interface called IAnimal.
[quoted text clipped - 12 lines]
> thanks,
> rodchar