title: Why this script doesn't work in C# properly, while it's working in PowerShell ISE
body: <p>I want to run a <code>PowerShell</code> script to get <code>ContentType</code>(s) of a list via C#.
  In the PowerShell the following script works:</p>
  
  <pre><code>$list.ContentTypes[0].Name
  </code></pre>
  
  <p>I want to have same result when I'm running it in C# as follows:</p>
  
  <pre><code>powershell.AddScript(string.Format("$web = Get-SPWeb {0}", testWeb));
  powershell.AddScript("$web.Lists");
  var psObjects = powershell.Invoke();
  
  foreach (var psObject in psObjects)
  {
      var currentList = (dynamic)psObject;
      powershell.Runspace.SessionStateProxy.SetVariable("list", psObject);
      powershellContentTypes.AddScript("$list.ContentTypes");
      var psContentTypes = powershellContentTypes.Invoke();
  
      foreach (dynamic psContentType in psContentTypes)
      {
          // I expect to psContentType to have Name property.
          // But its properties are like string.
          var name = psContentType.Name
      }
  }
  </code></pre>
  
  <p>But, unforunately, the <code>psContentType</code> has not any <code>Name</code> property. All of returned <code>psContentTypes</code> are of type <code>string</code> with this value: "Microsoft.SharePoint.SPContentType"</p>
  
  <p>What's wrong with my script in C#?</p>