interface type

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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)
 
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.
 
Use CType(_animal, Object).GetType.ToString()

As _animal is an interface you see only what is related to this interface.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top