Example Code

Using the .NET IEnumerator Interface in LabVIEW

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW

Code and Documents

Attachment

Download All

Overview

Demonstrates how to use the .NET System.Collections.IEnumerable interface to convert a .NET array into a LabVIEW array.

 

 Description

An example of looping through a .NET collection via the System.Collections.IEnumerable interface. Many of the collection classes don't support the ToArray() method, which means accessing the data from LabVIEW requires the IEnumerator. In C# or VB.NET examples, you most often see the "foreach" statement being used - which is a shorthand way of telling the compiler to use IEnumerator.So this example shows in complete detail how to take an IEnumerator interface and convert the list of elements into a LabVIEW Array.Note, a full conversion to a LabVIEW array can be very expensive for large collections, so think carefully about what it is you need from the collection before doing this. But regardless of your approach, the example should show the basics of using the interface.

 

Requirements:

  • LabVIEW 2012 (or compatible)
  • .NET Framework 1.1 SP1 or later

 

Steps to Implement or Execute Code
1. Run the VI.

2. The program adds 100 random numbers to an .NET array list
3. Afterwards the array is read back into LabVIEW using the IEnumerator interface

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
Blessing_Star
Member
Member
on

I tried my best. Would you help me to get Array of SearchCollection Data? Here is my Query, http://forums.ni.com/t5/LabVIEW/How-to-get-email-IDs-from-Exchange-Server-using-LDAP-without/td-p/19... Appriciate your answers.

Thanks