title: Beckhoff C# Reading array of string from PLC
body: <p>I want to ask about reading string array from PLC Beckhoff.</p>
  
  <p>I have some methods for reading Int16 - it works correctly</p>
  
  <pre><code>public Int16[] ReadArrFromPLC_Int16(string Mnemonic, int ArrLength)
  {
      Int16[] TempVariable = null;
  
      try
      {
          ITcAdsSymbol itc = PLC3.adsClient.ReadSymbolInfo(Mnemonic);
          long indexGroup = itc.IndexGroup; ;
          long indexOffset = itc.IndexOffset;
  
          int[] args = { ArrLength }; 
          TempVariable = (Int16[])PLC3.adsClient.ReadAny(indexGroup, indexOffset, typeof(Int16[]) , args);
      }
      catch (Exception ex)
      {
          MessageBox.Show(ex.Message, Mnemonic);
      }
      return TempVariable;
  }
  </code></pre>
  
  <p>but if I want to read array of string I get some exception: "Unable to marshal type. Parameter Name: type" in bold place:
  ...adsClient.ReadAny(indexGroup, indexOffset, <strong>typeof(string[])</strong>, args);</p>
  
  <pre><code>public string[] ReadArrFromPLC_String(string Mnemonic, int ArrLength)
  {
      string[] TempVariable = null;
  
      try
      {
          ITcAdsSymbol itc = PLC3.adsClient.ReadSymbolInfo(Mnemonic);
          long indexGroup = itc.IndexGroup; ;
          long indexOffset = itc.IndexOffset;
  
          int[] args = { ArrLength };
          TempVariable = (string[])PLC3.adsClient.ReadAny(indexGroup, indexOffset, typeof(string[]), args);
      }
      catch (Exception ex)
      {
          MessageBox.Show(ex.Message, Mnemonic);
      }
      return TempVariable;
  }
  </code></pre>
  
  <p>I can read the array in loop but it take long time.</p>
  
  <p>I found similar topic:
  <a href="https://stackoverflow.com/questions/8009787/marshalasattribute-array-of-strings">MarshalAsAttribute array of strings</a>
  but I don't know does it help me?
  and I don't know how I can use it in my case.</p>