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 / Languages / Managed C++ / September 2005

Tip: Looking for answers? Try searching our database.

Check if object is of a given type - elegant way (C++/CLI)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
moose - 07 Sep 2005 15:03 GMT
In C# I can write:
if(someObj is someType)
{ .. }

In C++/CLI I used:
if(someObj->GetType()->Eqals(someType::typeid))
{ .. }

Is there some other way to do this stuff in C++/CLI? Perhaps something more
elegant, like C# "is" keyword?
William DePalo [MVP VC++] - 07 Sep 2005 20:29 GMT
> In C# I can write:
> if(someObj is someType)
[quoted text clipped - 7 lines]
> more
> elegant, like C# "is" keyword?

Yes you can. Take a look at section 5.3 of this link

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvs05/html/Tra
nsGuide.asp


which discusses typeid.

Regards,
Will
William DePalo [MVP VC++] - 07 Sep 2005 22:29 GMT
>> In C# I can write:
>> if(someObj is someType)
[quoted text clipped - 13 lines]
>
> which discusses typeid.

Oops. Sorry. I see now that I offered you nothing new. :-(

Regards,
Will
vetplakh - 07 Sep 2005 23:38 GMT
Check out
http://msdn2.microsoft.com/library/85af44e9(en-us,vs.80).aspx

> In C# I can write:
> if(someObj is someType)
[quoted text clipped - 6 lines]
> Is there some other way to do this stuff in C++/CLI? Perhaps something more
> elegant, like C# "is" keyword?

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.