How get the array size using dynamic type
<p>I am getting an <code>array</code> when I <code>deserialize</code> my <code>JSON</code>.</p>

<p>I can access the <code>array</code> with <code>foreach</code>.</p>

<pre><code>dynamic obj = Newtonsoft.Json.JsonConvert.DeserializeObject(json);
foreach (dynamic result in  obj.Results.output1.value.Values)
{
}
</code></pre>

<p>But I need to get <code>size</code> of the <code>array</code> to access the last element direct.</p>

<p>Eg.</p>

<pre><code>obj.Results.output1.value.Values[size-1]
</code></pre>

<p>How can I do that?</p>

<h3>Edit 1</h3>

<p>I need to get for example the <code>"Y"</code> in <code>"Values"</code></p>

<pre><code>{
  "Results": {
    "output1": {
      "type": "table",
      "value": {
        "ColumnNames": [
          "I01",
          "I02",
          "I03",
          "O01",
          "Scored Probabilities for Class \"0\"",
          "Scored Probabilities for Class \"1\"",
          "Scored Probabilities for Class \"2\"",
          "Scored Labels"
        ],
        "Values": [
          [
            "-0.96624",
            "0.02918",
            "-0.44237",
            null,
            "3.25456957391002E-12",
            "0.000107838139228988",
            "2.76633869589205E-07",
            "Y"
          ]
        ]
      }
    }
  }
}
</code></pre>

<h3>Edit 2</h3>

<p>If I print I get this <code>JSON</code></p>

<pre><code>Console.WriteLine(obj.Results.output1.value.Values);

[
    [
        "-0.96624",
        "0.02918",
        "-0.44237",
        null,
        "3.25456957391002E-12",
        "0.000107838139228988",
        "2.76633869589205E-07",
        "Y"
    ]
]
</code></pre>

<p>And the Count prints <code>1</code></p>

<pre><code>Console.WriteLine(obj.Results.output1.value.Values.Count);
</code></pre>

<p>I almost there, I need the last element o the <code>size</code> to access by index in the inside <code>array</code>.</p>

<h3>Edit 3</h3>

<p>I could get the last element with:</p>

<pre><code>Console.WriteLine(obj.Results.output1.value.Values[0].Last);
</code></pre>

<p>And the array size with:</p>

<pre><code>Console.WriteLine(obj.Results.output1.value.Values[0].Count);
</code></pre>