Length of a list C#

I am trying to create a zerotouch node and I want to feed in a list of numbers. Then get the size of the list and perform a loop operation on the list. When I use the “int lena = a.Length;” below I get this message,

“‘double’ does not contain a definition for ‘Length’ and no extension method ‘Length’ accepting a first argument of type ‘double’ could be found (are you missing a using directive or an assembly reference?)”

Can someone give me some insight into why this is? A portion of my test code is below. Thanks very much for any info.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.DesignScript.Runtime;

namespace ZeroTouchExample
public class ZeroTouchExample

    [MultiReturn(new[] { "add", "mult" })]
    public static Dictionary<string, object> ReturnMultiExample(double a, double b)

        int lena = a.Length;

Might try changing your input to an actual list. Currently, it is a single item (int). Also, a count will return a number of items in the list.

    [MultiReturn(new[] { "add", "mult" })]
    public static Dictionary<string, object> ReturnMultiExample(List<double> a, List<double> b)
        int lena = a.Count;

Thanks John, that is exactly what I needed.

1 Like

More on…C# List