title: How to insert the LINQ result to a string[] array
body: <p>I have a one dimensional string[] array as follows </p>
  
  <pre><code>string[] header = new string[30];
  
      public class GetList
      {
          public string ServerID;
          public string Name;
  
          public GetList(string sName, string cName)
          {
              this.ServerID = sName;
              this.Name = cName;
          }
      }        
  </code></pre>
  
  <p>and I have a query which will return the list of server names and component names as follows</p>
  
  <pre><code>   var query = (from a in this.hmdb.Servers
                  join b in this.hmdb.Components
                  on a.ServerID equals b.ServerID
                  select new { a.ServerID, b.Name});
  </code></pre>
  
  <p>how to insert the query result into the string[] header ? </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>when i tried something like this</p>
  
  <pre><code>  var query = (from a in this.hmdb.Servers
                       where a.ServerID.Contains(match)
                       join b in this.hmdb.Components
                       on a.ServerID equals b.ServerID
                       select new
                           {
                               ID = a.ServerID,
                               Name = b.Name
                           }).ToArray();
  </code></pre>
  
  <p>I get the result as list of ServerID and Names</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>here is the explanation for the marked answer..</p>
  
  <p>what's happening is that it will create a queryable/list of ServerID and Name then convert it to Enumerable and create a List of string using the .Select() extension and convert it to array of string
  select new { a.ServerID, b.Name } --> creates a list/iqueryable of anonymous type that has ServerID and Name properties.. </p>
  
  <p>AsEnumerable() --> convert it to Enumerable so we can use string.Format because SQL to LINQ doesn't support string.Format </p>
  
  <p>Select(x => string.Format("{0} - {1}", x.ServerID, x.Name)) --> do a Select in order to create a list of String using the ServerID and Name </p>
  
  <p>ToArray() --> simply convert it to a String[]
  there.</p>