List(of T) in journal

I'm wondering if anyone here could help with this.

I'm trying to use list(Of T) in a journal and I keep getting:
"Type 'List' is not defined.."

Is there an import that I need to use before I can use a list?

Thanks for any info

I found the solution. I have to use

collections.generic.list(of T)

If you add the imports statement:
Imports System.Collections.Generic

at the top of the journal, then you can just use the initial syntax that you tried rather than typing out "Collections.Generic.List" each time.
for example:
Dim myList as New List(of NXObject)

That works but there is still a problem.

I'm not able to use .max on my list of items now.

Is there a good way to find which imports are required on a specific command?

If it is .NET functionality that you need information on, MSDN is the place to go.
http://msdn.microsoft.com/en-us/library/ff361664%28v=vs.110%29.aspx

If you can post a small code sample that shows the problem you are having, we might be able to find a solution.

Thanks for the info, I will look around on the Microsoft site and see what I can find out also.

Here is the portion of my code that is causing the problem. Specifically the "List_val.max" is what I can't get to work.

Dim LIST_VAL As New List(of Double)

LIST_VAL.Add(x(3) - x(0))
LIST_VAL.Add(y(4) - y(1))
LIST_VAL.Add(z(5) - z(2))

msgbox ("Length: " & List_val.Max)

I was able to find a work around for now and use an array in place of a list and "sort" it instead. I would still like to find a solution so that I can use "list.max" down the road though.

Thanks again.

Is it safe to assume that x(), y(), and z() are defined as arrays of doubles?

The .Max method is an "extension" method. It seems to work fine if I create a "console application" but I can't seem to get it to work in a journal. It probably has to do with the limitations of journals, though I have not verified that yet.

Side note: you do not have to convert to an array to sort the values. You can use the .Sort method on the list itself, the max value will then be the first or last value in the list (after using the .Sort method you can use the .Reverse method to reverse the sort order).

The Max method on Lists lives in the System.Linq assembly. A refeerence to this assembly is added to a console application by default. When programming in the NX Journal Editor, you can't add a reference to System.Linq, so you can't use any of the extension methods contained therein.

That's what I was afraid of, thanks for the verification.

If you have IDE environment as .Net framework 3.5 or higher then no need to add any reference, just System reference is enough. Just write using System.Linq or Imports System.Linq. Then it should work.

~ Ankita

Life is beautiful. :)