1) What is the ".NET way" of representing this same kind of interface? A single method returning an array<>? Does the array<> generic have iterators, so that I could implement BeginLocals() and EndLocals()?

2) Should Local be declared as a value struct in the .NET wrapper?

I'd really like to represent the wrapped class with a .NET flavor, but I'm very new to the managed world - and this type of information is frustrating to google for...

So really, the ".net way" would be to simply allow people to create List< Local > items for themselves. If you do want to control iteration or make the collection a bit more custom, have your collection implement the IEnumerable< T > and/or ICollection< T > interfaces as well.

A near direct translation to c# would be pretty much what you assumed:

@Phillip - Thanks, your answer really got me started in the right direction.

After seeing your code, and doing a little more reading in Nish's book C++/CLI in Action, I think using an indexed property that returns a const tracking handle to a Local instance on the managed heap is probably the best approach. I ended up implementing something similar to the following:

That's a good approach, but you'll probably want to also make sure to expose a Count property at least :). One other note, without exposing the list or implementing IEnumerable< T >, the class won't be usable by the LINQ extensions in .net 3.5
–
Philip RieckSep 17 '08 at 20:38