title: C# array to javascript array
body: <p>I have two method in my code behind one returns an int array and the other returns string array.
  I want to use these two array to populate the google chart data table.</p>
  
  <p>I do not have any experience with Json or AJAX however I found a relatively simple solution using the string.Join and eval to convert the string to an array.</p>
  
  <p>I have managed to do this with the int array however I found a problem with the string array. I know that the problem is that I need to add '' to each  element in the array.</p>
  
  <pre><code>function drawChart() {
  
      var locality = ['Loc_A', 'Loc_B', 'Loc_C', 'Loc_D', 'Loc_E'];
      //var locality =  eval('[&lt;% =string.Join(", ", locations)%&gt;]');
      var frequency = eval('[&lt;% =string.Join(", ", numbers ) %&gt;]'); 
  
      var data = new google.visualization.DataTable();
      data.addColumn('string', 'locality');
      data.addColumn('number', 'frequency');
  
      for (i = 0; i &lt; locality.length; i++)
          data.addRow([locality[i], frequency[i]]);
  
      var options = {
           title: 'Test'
       };
  
      var chart = new google.visualization.PieChart(document.getElementById('piechart'));
      chart.draw(data, options);
  }
  </code></pre>
  
  <p>I need to adjust the commented line by adding '' with each word so that then I can convert the string to a javascript array.</p>
  
  <p>Any ideas or any other hints howto convert c# arrays  from code behing to java script arrays. Code examples would be very helpful please.</p>