title: How to encode an array of elements to HTML
body: <p>I have an array full of strings that have been taken from a form. I need to convert each element of the array to HTML before I post it to my database, in order to stop SQL errors occurring.</p>
  
  <p>Here is a snippet of the array:</p>
  
  <pre><code>string[] device = {Request["image"] ,  Request["name"] , Request["nettech"] , Request["announced"] , Request["status"]};
  </code></pre>
  
  <p>I am using ASP, Razor and C# in addition to HTML and CSS to code the website. Is there an easy way to encode all the array elements, instead of doing them all individually (which works, just looking for a shorter, tidier way of doing things)?</p>
  
  <p>This is how I am currently encoding them:</p>
  
  <pre><code>string image = Server.HtmlEncode(device[0]);
  string name = Server.HtmlEncode(device[1]);
  </code></pre>