title: Confused on C# Array of objects and implicit type conversion
body: <p>I am trying to pass an array of a simple object to a web service and I'm really stuck on this error during compile of my web client project:</p>
  
  <p>Cannot implicitly convert type 'TRIMBrokerUtil.MetaData[]' to 'TRIMBrokerASMXProxy.ASMXProxy.MetaData[]'</p>
  
  <p>Here is my "utility" project compiled into TRIMBrokerUtil.dll:</p>
  
  <pre><code>namespace TRIMBrokerUtil
  {
      public class MetaData
      {
      protected string _Name;
      protected string _Value;
      public MetaData(string keyword, string setting) 
      {
          this.Name = keyword;
          this.Value = setting;
      }
      public string Name
      {
          get
          {
          return this._Name;
          }
          set
          {
          Name = value;
          }
      }
      public string Value
      {
          get
          {
          return this._Value;
          }
          set
          {
          _Value = value;
          }
      }
      }
  </code></pre>
  
  <p>Here is a snippet of the web service which also compiles fine:
      using TRIMBrokerUtil;
      namespace TRIMBrokerService
      {
          [WebService(Namespace = "<a href="http://tempuri.org/" rel="nofollow noreferrer">http://tempuri.org/</a>")]
          [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
          [ToolboxItem(false)]
          public class FileService : System.Web.Services.WebService
          {</p>
  
  <pre><code>    [WebMethod]
      public string UploadFile(byte[] incomingArray
          , string FileName
          , long FileLengthInBytes
          , MetaData[] metaDataArray)
      {
  </code></pre>
  
  <p>...and usage later as this:</p>
  
  <pre><code>Update update = BuildMetaData(metaDataArray);
  </code></pre>
  
  <p>...and this:</p>
  
  <pre><code>private Update BuildMetaData(MetaData[] nvPairs)
  {
      Update update = new Update();
      InputProperty[] ip = new InputProperty[nvPairs.Length];
      int i;
      for (i=0; i &lt; nvPairs.Length; i++)
      {
      ip[i].Name = "udf:" + nvPairs[i].Name;
      ip[i].Val = nvPairs[i].Value;
      }
      update.Items = ip;
      return update;
  }
  </code></pre>
  
  <p>Next, (via "Add Web Reference") I have my proxy class for the ASMX webservice in a separate project and it compiles without problem. Inside the generated reference.cs file I find this which seems OK:</p>
  
  <pre><code>    [System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/UploadFile", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
      public string UploadFile([System.Xml.Serialization.XmlElementAttribute(DataType="base64Binary")] byte[] incomingArray, string FileName, long FileLengthInBytes, MetaData[] metaDataArray) {
          object[] results = this.Invoke("UploadFile", new object[] {
                      incomingArray,
                      FileName,
                      FileLengthInBytes,
                      metaDataArray});
          return ((string)(results[0]));
      }
  </code></pre>
  
  <p>Now for the error that occurs in compilation in the web client project (default.aspx.cs):</p>
  
  <pre><code>    using TRIMBrokerUtil;
  
  public partial class _Default : System.Web.UI.Page
  {
      private void UploadFile(HttpPostedFile postedFile
                  , string fileNameOnly
                  , MetaData[] metaDataArray)
      {
          string strURI = string.Empty;
          TRIMBrokerASMXProxy.ASMXProxy.FileService client = new TRIMBrokerASMXProxy.ASMXProxy.FileService();
          BinaryReader b = new BinaryReader(postedFile.InputStream);
          byte[] binData = b.ReadBytes(numBytes);
          TRIMBrokerASMXProxy.ASMXProxy.MetaData[] kvData = metaDataArray; // error complains about this line
          strURI = client.UploadFile(binData, fileNameOnly, binData.Length, kvData );
  </code></pre>
  
  <p>I have also tried changing the last 2 lines above to simply this one line:</p>
  
  <pre><code>strURI = client.UploadFile(binData, fileNameOnly, binData.Length, metaDataArray);
  </code></pre>
  
  <p>...but that change introduces a 2nd error from the compiler which reads as: </p>
  
  <p>The best overloaded method match for 'TRIMBrokerASMXProxy.ASMXProxy.FileService.UploadFile(byte[], string, long, TRIMBrokerASMXProxy.ASMXProxy.MetaData[])' has some invalid arguments  </p>
  
  <p>(note the original error about "cannot convert" is the 2nd error). </p>
  
  <p>Sorry about being so verbose above. Hope you can help shed light on this confusion.</p>