LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I create a .NET List?

Solved!
Go to solution

So how do you get the .NET constant initialized to a list of strings?  Did you do a Create->Constant somewhere, or can you specify a refnum's class by name?

 

Thanks,

Nathan

0 Kudos
Message 11 of 30
(4,015 Views)

Hello Nathan,

 

Thank you for your question regarding .NET. I am just wondering if you can elaborate on your question and/or post a screenshot of your code so that we can better assist you.

Warm Regards,

Josh
0 Kudos
Message 12 of 30
(3,976 Views)

I was referring to the OP's answer in message 2, which has a screenshot including a specific .NET refnum constant. How did he get it?  I have a temporary workaround where I make a .NET DLL with the desired refnum type as an output, from which I simply create a constant.  If there is a way of specifying the type by string, that would be a little cleaner, as much as I relish the oppurtunity to pull up Visual Studio 🙂

Message 13 of 30
(3,971 Views)

Hello Nathan,

 

Thank you for clarifying. You can create a list using an enum, then you can convert the output of the enum to a string and use that as the constant for the .NET refnum. You can find this here: Enum to String. You would be replacing the string constant in the sample OP provided with that conversion (that results in a string constant as defined by the enum. Please let me know if this helps answer your question.

Warm Regards,

Josh
0 Kudos
Message 14 of 30
(3,932 Views)

I know that this thread is quite old but it was helpful for my application. I think the issue Garousi was having, and myself as well with the null pointer exception, is that the example has a space in between List` 1 where it should be List`1. Once I found that, the example worked like a charm.

 

So:

System.Collections.Generic.List` 1[System.String]

should be:

System.Collections.Generic.List`1[System.String]

 

You can populate the .NET list using the add or insert methods in the invoke node.

 

Thanks for your solution to this Jim_Kring.

 

0 Kudos
Message 15 of 30
(3,840 Views)

Could you please tell me how to get To More Specific Class  .NET reference (System.Collections.Generic.List`1[System.String])? I got every piece except that. 

0 Kudos
Message 16 of 30
(3,579 Views)

Are you referring to the .NET reference wired into the top of the To More Specific Class function?

0 Kudos
Message 17 of 30
(3,541 Views)

I guess he does... me having the same question

0 Kudos
Message 18 of 30
(3,347 Views)

I've been trying for ages to work out how to create an instance of an Enumerable list for use when defining the pipeline for a MongoDB aggregation (basically a list of BSON documents, which specify the operation in each stage in the aggregation).

 

This solved my problem.

 

Great stuff!.

0 Kudos
Message 19 of 30
(2,967 Views)

I've just realised that you can do this too...

 

Create DOTNET List.png

 

For some reason I'd always overlooked this VI, but it seems pretty powerful.

 

Message 20 of 30
(2,955 Views)