Passing array of strings from c# to javascript
<p>I am building two arrays in c# and pass them to a js function like this:</p>

<pre><code>            //call js to show the map with the markers
        string[] lats = new string[10];
        string[] longs = new string[10];

        for (int i = 0; i &lt; 10; i++)
        {
            lats[i] = dv[i]["Latitude"].ToString();
        }

        for (int i = 0; i &lt; 10; i++)
        {
            longs[i] = dv[i]["Longitude"].ToString();
        }

        StringBuilder sbLats = new StringBuilder();
        string[] latsArray = lats.ToArray&lt;string&gt;();

        //Build the JS array.
        sbLats.Append("[");
        for (int i = 0; i &lt; latsArray.Length; i++)
        {
            sbLats.AppendFormat("'{0}', ", latsArray[i]);

        }
        sbLats.Append("]");

        StringBuilder sbLongs = new StringBuilder();
        string[] longsArray = longs.ToArray&lt;string&gt;();

        //Build the JS array.
        sbLongs.Append("[");
        for (int i = 0; i &lt; longs.Length; i++)
        {
            sbLongs.AppendFormat("'{0}', ", longsArray[i]);

        }
        sbLongs.Append("]");


        ScriptManager.RegisterStartupScript(this, this.GetType(), "mapMarket", "buildMapWithMarkers('map_market', " + latsArray + ", " + longsArray + ", " + "false" + ");", true);
</code></pre>

<p>For some unknown reason this throws an exception here (in the aspx page, part of generated js):</p>

<pre><code>buildMapWithMarkers('map_market', System.String[], System.String[], false)
</code></pre>

<p>which says:</p>

<pre><code>Uncaught SyntaxError: Unexpected token ]
</code></pre>

<p>Can you please tell me where I am wrong?</p>
