Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

New Post: Passing an array in Clearscript to a C# object

$
0
0
Hi,

I just wanted to point out that I found a solution...

Here is the modifed NTimes function:
    public int NTimes(dynamic values, int targetValue)
    {
        int answer = 0;

        List<int> intVals = new List<int>();


        for (var i = 0; i < values.length; i++)
            intVals.Add(Convert.ToInt16(values[i]));

            foreach (int val in intVals)
            {
                if (val == targetValue)
                    answer++;
            }


        return answer;
    }

The trick was changing it to a dynamic type and then converting from there into integers.

Viewing all articles
Browse latest Browse all 2297

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>