In an earlier post, I described how to convert an ArrayList into a LabVIEW array via the ToArray() method. However, many of the collection types in .NET do not support this method - instead you must use the IEnumerator interface.
After receiving some questions on how best to do this, I created this example to demonstrate the way to loop through the values in the collection.
Things to remember...
- This can be expensive for large collections. Converting the collection to a LabVIEW array can make later code easier to write, but make sure the performance is acceptable.
- As I show in the example, watch for loose refnums. This is an easy place to forget to close your refnums and end up with a memory leak.
- This same example works for searching or any other algorithm where you need to look through the collection monotonically...it isn't just for converting to a LabVIEW array.
Comments