Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / July 2007

Tip: Looking for answers? Try searching our database.

interface type

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rodchar - 10 Jul 2007 21:34 GMT
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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.