title: how to convert array with keys/values to JSON c#
body: <p>I'm completey new to C# and I've already given myself a headache. I know this is probably kids stuff to you, but I've spent an hour+ googleing around and can't seem to work it out.</p>
  
  <p>All I'm trying to do is convert an array into JSON. I know PHP well, so here's an example of what I'm trying to do (in PHP):</p>
  
  <pre><code>$myarr=array("key1"=&gt;"value for key 1","key2"=&gt;"value for key 2");
  
  $jsonArray=json_encode($myarr);
  </code></pre>
  
  <p>so <code>$jsonArray</code> will be: <code>{"key1":"value for key 1","key2":"value for key 2"}</code></p>
  
  <p>Now, I'm trying to do exactly that, but in C#.</p>
  
  <p>This is what I have so far:</p>
  
  <pre><code> String[] keys = new String[] { "emailSend","toEmail"};
   String[] values = new String[] {textBox2.Text,textBox1.Text};
   JavaScriptSerializer js = new JavaScriptSerializer();
   string json = js.Serialize(keys);//final json result
   MessageBox.Show(json);//show me
  </code></pre>
  
  <p>I'm using Visual Studio C# 2010, which is throwing this error (with the code above): </p>
  
  <blockquote>
    <p>The type or namespace name 'JavaScriptSerializer' could not be found
    (are you missing a using directive or an assembly reference?)</p>
  </blockquote>
  
  <p>Any ideas on what I'm doing wrong here? Thanks</p>