tags:

views:

44

answers:

1

Hello:

Without using p/invoke, from a C++/CLI I have succeeded in integrating various methods of a DLL library from a third party built in C.

One of these methods retrieves information from a database and stores it in different structures. The C++/CLI program I wrote reads those structures and stores them in a List<>, which is then returned to the corresponding reading and use of an application programmed completely in C#. I understand that the double handling of data (first, filling in several structures and then, filling all of these structures into a list<>) may generate an unnecessary overload, at which point I wish C++/CLI had the keyword "yield".

Depending on the above scenario, do you have recommendations to avoid or reduce this overload?

Thanks.

A: 

You do not need the yield keyword to create iterators. Just create one class implementing IEnumerator<T> and another class implementing IEnumerable<T>.

Stephen Cleary
Thanks Stephen, do you know about a web site for getting some examples?
Here's one I found from Googling: http://www.brianensink.com/blog/post/Implementing-IEnumerable3cT3e-in-C2b2bCLI.aspx
Stephen Cleary