title: How to display PSObject in C#
body: <p>I'm building a PowerShell host by C#, and I want to display the result after invoking PowerShell. Now I use the following method:</p>
  
  <pre><code>public static string GetLogQueriedString(
      PSMemberInfoCollection&lt;PSPropertyInfo&gt; PSPropertyCollection)
  {
      string line = string.Empty;
      foreach (var item in PSPropertyCollection)
      {
          if (!line.Equals(string.Empty)) line += ",";
          line += item.Name + " : " + item.Value;
      }
  
      return line;
  }
  </code></pre>
  
  <p>It works if the PSObject has many properties that I need, but in this situation, if the PSObject is a string, the result is not what I want. It will display "Length: 40", rather than the string itself.</p>
  
  <p>And another question: if I execute several PowerShell commands, why will it display all the results, including the previous result. For example, I execute "ls; get-process", and it will display the result of "ls" and the result of "get-process".</p>