title: Convert C# 2D array (object [,]) to javascript 2D array
body: <p>I am writing an APS.NET MVC application that reads data from DB and presents it with google charts.</p>
  
  <p>I am reading the data from DB in C# into 2D array and need to pass it to my javascript code that generates the google chart.</p>
  
  <p>My Code:</p>
  
  <pre><code>ViewBag.Data = new object[,]
          {
              {"10:00:00",10},
              {"11:00:00", 20}
          };
  
  @{
      Object[,] arr = ViewBag.Data;    
  
  }
  </code></pre>
  
  <p>My Javascript code:</p>
  
  <pre><code>var jsArray = @Html.Raw(Json.Encode(arr));// Only working for 1D array
  var data = google.visualization.arrayToDataTable(jsArray);
  </code></pre>
  
  <p>I can't pass 2D array from my C# code to my javascript code to generate the wanted chart.
  I see only example for converting 1D arrays from C# to javascript (see above).</p>
  
  <p>Any ideas?</p>
  
  <p>Thanks</p>