title: Can I stop my WCF generating ArrayOfString instead of string[] or List<string>
body: <p>I am having a minor problem with WCF service proxies where the message contains <code>List&lt;string&gt;</code> as a parameter.</p>
  
  <p>I am using the 'Add Service reference' in Visual Studio to generate a reference to my service.</p>
  
  <pre><code>   // portion of my web service message
     public List&lt;SubscribeInfo&gt; Subscribe { get; set; }
     public List&lt;string&gt; Unsubscribe { get; set; }
  </code></pre>
  
  <p>These are the generated properties on my <code>MsgIn</code> for one of my web methods.
  You can see it used <code>ArrayOfString</code> when I am using <code>List&lt;string&gt;</code>, and the other takes <code>List&lt;SubscribeInfo&gt;</code> - which matches my original C# object above.</p>
  
  <pre><code>[System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false)]
  public System.Collections.Generic.List&lt;DataAccess.MailingListWSReference.SubscribeInfo&gt; Subscribe {
      get {
          return this.SubscribeField;
      }
      set {
          if ((object.ReferenceEquals(this.SubscribeField, value) != true)) {
              this.SubscribeField = value;
              this.RaisePropertyChanged("Subscribe");
          }
      }
  }
  
  [System.Runtime.Serialization.DataMemberAttribute(EmitDefaultValue=false)]
  publicDataAccess.MailingListWSReference.ArrayOfString Unsubscribe {
      get {
          return this.UnsubscribeField;
      }
      set {
          if ((object.ReferenceEquals(this.UnsubscribeField, value) != true)) {
              this.UnsubscribeField = value;
              this.RaisePropertyChanged("Unsubscribe");
          }
      }
  }
  </code></pre>
  
  <p>The ArrayOfString class generated looks like this. This is a class generated in my code - its not a .NET class. It actually generated me a class that inherits from List, but didn't have the 'decency' to create me any constructors.</p>
  
  <pre><code>    [System.Diagnostics.DebuggerStepThroughAttribute()]
      [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "3.0.0.0")]
      [System.Runtime.Serialization.CollectionDataContractAttribute(Name="ArrayOfString", Namespace="http://www.example.com/", ItemName="string")]
      [System.SerializableAttribute()]
      public class ArrayOfString : System.Collections.Generic.List&lt;string&gt; {
      }
  </code></pre>
  
  <p>The problem is that I often create my message like this :</p>
  
  <pre><code>client.UpdateMailingList(new UpdateMailingListMsgIn()
  {
      Email = model.Email,
      Name = model.Name,
      Source = Request.Url.ToString(),
      Subscribe = subscribeTo.ToList(),
      Unsubscribe = unsubscribeFrom.ToList()
  });
  </code></pre>
  
  <p>I really like the clean look this gives me.</p>
  
  <p>Now for the actual problem :</p>
  
  <p>I cant assign a <code>List&lt;string&gt;</code> to the <code>Unsubscribe</code> property which is an <code>ArrayOfString</code>  - even though it inherits from List. In fact I cant seem to find ANY way to assign it without extra statements.</p>
  
  <p>I've tried the following :</p>
  
  <ul>
  <li><code>new ArrayOfString(unsubscribeFrom.ToList())</code>  - this constructor doesn't exist :-(</li>
  <li>changing the type of the array used by the code generator   -  doesn't work - it always gives me ArrayOfString (!?)</li>
  <li>try to cast <code>List&lt;string&gt;</code> to <code>ArrayOfString</code>   - fails with 'unable to cast', even though it compiles just fine </li>
  <li>create <code>new ArrayOfString()</code> and then <code>AddRange(unsubscribeFrom.ToList())</code>   -  works, but I cant do it all in one statement</li>
  <li>create a conversion function <code>ToArrayOfString(List&lt;string&gt;)</code>, which works but isn't as clean as I want.</li>
  </ul>
  
  <p>Its only doing this for string, which is annoying.</p>
  
  <p>Am i missing something? Is there a way to tell it not to generate <code>ArrayOfString</code> - or some other trick to assign it ?</p>