Rob Garrett - Blogs

Welcome to Rob Garrett - Blogs Sign in | Join | Help
in Search
Google

Software/Technology Discussion

Software and Technology Tid-bits

From C++ to C#

I have gone back in time this week to work on a legacy ISAPI application.  The ISAPI application is being developed in C++ and makes use of MSXML to read an XML configuration file.  Below is some code in C++ to open the XML file and read two text values, contained in element nodes:

Now, here is the code in C#:

Much easier huh?  See how far we've come as developers.  Whilst writing my ISAPI application I had to remember to go back and clean up my memory allocations because there is no friendly garbage collector doing it for me - doh.
Share this post: Email it! | bookmark it! | digg it! | reddit!
Published Monday, November 28, 2005 4:04 PM by Rob Garrett

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

 

Nathan said:

Definitely a bit easier to read. Although I would submit that the API is more of an issue than the language itself... Dealing with COM is never what I would call pleasant. (The code would look remarkably the same in managed C++...)
November 30, 2005 9:45 AM
 

Rob Garrett said:

Hmmm, I would agree with your comment about the API, but have to disagree about interfacing with COM from .NET. The framework makes COM interop a breeze. Just add a reference to the COM object from inside Visual Studio and all the plumbing and marshalling code is handled by the framework. The developer is presented with a nicely typed class representing the CoClass in the COM component.
November 30, 2005 10:23 AM

Leave a Comment

(required) 
(optional)
(required) 
Submit

Blurb


Head Shot
Rob Garrett is a British Expat living in Maryland USA. Rob is a trained software engineer and experienced in Windows .NET development.

Rob enjoys listening to Rock music, posting to blogs, driving in the country with the sunroof open, beer (not in conjunction with country driving) and spending time with his family.

This Blog

Syndication

Powered by Community Server, by Telligent Systems