title: How to write strings from foreach loop to console one line at a time?
body: <p>I'm working on a solution to get the name and id of a set of tests from an API. All of the data is found and returned as I can see the data in the Output window in Visual Studio. </p>
  
  <pre><code>// method to get the test names and id numbers
      public List&lt;Asset&gt; GetTests()
      {
          var assetType = _context.MetaModel.GetAssetType("Test");
          var query = new Query(assetType);
          var nameAttribute = assetType.GetAttributeDefinition("Name");
  
  
          query.Selection.Add(nameAttribute);
  
          var result = _context.Services.Retrieve(query);
  
          result.Assets.ForEach(test =&gt;
              LogResult(test.Oid.Token,
                  GetValue(test.GetAttribute(nameAttribute).Value)));
  
          return result.Assets;
      }
  </code></pre>
  
  <p>I have two other methods, one to check for null values and the other to display the output to the Output window in Visual Studio. </p>
  
  <pre><code>    private static string GetValue(object value)
      {
          return value == null ? "No Value Available" : value.ToString();
      }
  
      private static void LogResult(params string[] results)
      {
          foreach (var result in results)
          {
              System.Diagnostics.Debug.Write(result);
          }
      }
  </code></pre>
  
  <p>When I step through the code I see that the two values, id number and test name, are displaying to the console window successfully. The data is displayed in the output window in one line. </p>
  
  <p><code>Test:1142Sample: Login Criterion Test:1147Sample: Add Customer Details CriterionTest:1153Sample: Add Customer Header</code></p>
  
  <p>Of course if I write out to the console the results are all jumbled together. </p>
  
  <p>How do you display the results in the Console Window as:</p>
  
  <pre><code>    Test:1142     Name: Login Criterion
      Test:11475    Name: Add Customer Details
      Test:1153     Name: Add Customer Header
  </code></pre>
  
  <p>Basically, the output is correct but I would like to format the data to display neatly in the Console Window. </p>
  
  <p>I see an example here, <a href="http://www.dotnetperls.com/console-writeline" rel="nofollow">http://www.dotnetperls.com/console-writeline</a>, but it looks like you have to know how many values will be returned in order to format the display correctly. Would you use an array to achieve this?</p>
  
  <pre><code>static void Main()
  {
  string value1 = "Dot";
  string value2 = "Net";
  string value3 = "Perls";
  
  Console.WriteLine("{0}, {1}, {2}", // &lt;-- This is called a format string.
      value1,                        // &lt;-- These are substitutions.
      value2,
      value3);
  }
  </code></pre>