title: C++/cli: Cannot convert parameter 1
body: <p>I am trying to convert a C# code which works with a DLL into C++, so my c++ application can work with the DLL. So here I am developing a C++/cli application</p>
  
  <p>I am working on this C# code:</p>
  
  <pre><code>private void SendUSBData(byte[] Data)
  {
      if (this.USB.SpecifiedDevice != null)
      {
          this.USB.SpecifiedDevice.SendData(Data);
      }
  }
  </code></pre>
  
  <p><code>SendData()</code> is a method available in the dll. Following is it's definition in dll</p>
  
  <pre><code>public void SendData(byte[] data);
  </code></pre>
  
  <p>OK, now in my C++ code, I tried to convert C# code like this</p>
  
  <pre><code>void MissileLauncher::sendUSBData(unsigned char *data)
  {
      if(usb.SpecifiedDevice!=nullptr)
      {
          //System::Byte
          usb.SpecifiedDevice-&gt;SendData(&amp;data);
      }
  }
  </code></pre>
  
  <p>I get the following error when I run this code</p>
  
  <pre><code>1&gt;------ Build started: Project: CallToCSharp, Configuration: Debug Win32 ------
  1&gt;  MissileLauncher.cpp
  1&gt;MissileLauncher.cpp(200): error C2664: 'UsbLibrary::SpecifiedDevice::SendData' : cannot convert parameter 1 from 'unsigned char **' to 'cli::array&lt;Type,dimension&gt; ^'
  1&gt;          with
  1&gt;          [
  1&gt;              Type=unsigned char,
  1&gt;              dimension=1
  1&gt;          ]
  ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  </code></pre>
  
  <p>I tried the following as well</p>
  
  <pre><code>void MissileLauncher::sendUSBData(array&lt;System::Byte&gt;^data)
  {
      if(usb.SpecifiedDevice!=nullptr)
      {
          //System::Byte
          usb.SpecifiedDevice-&gt;SendData(&amp;data);
      }
  }
  </code></pre>
  
  <p>it gave me the following error</p>
  
  <pre><code>1&gt;------ Build started: Project: CallToCSharp, Configuration: Debug Win32 ------
  1&gt;  MissileLauncher.cpp
  1&gt;MissileLauncher.cpp(125): error C2664: 'MissileLauncher::sendUSBData' : cannot convert parameter 1 from 'unsigned char *' to 'cli::array&lt;Type&gt; ^'
  1&gt;          with
  1&gt;          [
  1&gt;              Type=unsigned char
  1&gt;          ]
  1&gt;MissileLauncher.cpp(159): error C2664: 'MissileLauncher::sendUSBData' : cannot convert parameter 1 from 'unsigned char *' to 'cli::array&lt;Type&gt; ^'
  1&gt;          with
  1&gt;          [
  1&gt;              Type=unsigned char
  1&gt;          ]
  1&gt;MissileLauncher.cpp(164): error C2664: 'MissileLauncher::sendUSBData' : cannot convert parameter 1 from 'unsigned char *' to 'cli::array&lt;Type&gt; ^'
  1&gt;          with
  1&gt;          [
  1&gt;              Type=unsigned char
  1&gt;          ]
  1&gt;MissileLauncher.cpp(166): error C2664: 'MissileLauncher::sendUSBData' : cannot convert parameter 1 from 'unsigned char *' to 'cli::array&lt;Type&gt; ^'
  1&gt;          with
  1&gt;          [
  1&gt;              Type=unsigned char
  1&gt;          ]
  1&gt;MissileLauncher.cpp(186): error C2664: 'MissileLauncher::sendUSBData' : cannot convert parameter 1 from 'unsigned char *' to 'cli::array&lt;Type&gt; ^'
  1&gt;          with
  1&gt;          [
  1&gt;              Type=unsigned char
  1&gt;          ]
  1&gt;MissileLauncher.cpp(188): error C2664: 'MissileLauncher::sendUSBData' : cannot convert parameter 1 from 'unsigned char *' to 'cli::array&lt;Type&gt; ^'
  1&gt;          with
  1&gt;          [
  1&gt;              Type=unsigned char
  1&gt;          ]
  1&gt;MissileLauncher.cpp(200): error C2664: 'UsbLibrary::SpecifiedDevice::SendData' : cannot convert parameter 1 from 'cli::array&lt;Type&gt; ^*' to 'cli::array&lt;Type&gt; ^'
  1&gt;          with
  1&gt;          [
  1&gt;              Type=unsigned char
  1&gt;          ]
  ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  </code></pre>
  
  <p>How can I get rid of this?</p>
  
  <h2>Update</h2>
  
  <p>As proposed in an answer, I tried the following code</p>
  
  <pre><code>void MissileLauncher::sendUSBData(unsigned char *data)
  {
      if(usb.SpecifiedDevice!=nullptr)
      {
          int N = 10;
              cli::array&lt;char&gt;^ newData = gcnew cli::array&lt;char&gt;(N);
  
          for (int i = 0; i &lt; N; ++i)
              newData[i] = data[i];
  
          //System::Byte
          usb.SpecifiedDevice-&gt;SendData(newData);
      }
  }
  </code></pre>
  
  <p>Now, it is giving me the below error</p>
  
  <pre><code>1&gt;------ Build started: Project: CallToCSharp, Configuration: Debug Win32 ------
  1&gt;  MissileLauncher.cpp
  1&gt;MissileLauncher.cpp(206): error C2664: 'UsbLibrary::SpecifiedDevice::SendData' : cannot convert parameter 1 from 'cli::array&lt;Type&gt; ^' to 'cli::array&lt;Type,dimension&gt; ^'
  1&gt;          with
  1&gt;          [
  1&gt;              Type=char
  1&gt;          ]
  1&gt;          and
  1&gt;          [
  1&gt;              Type=unsigned char,
  1&gt;              dimension=1
  1&gt;          ]
  ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  </code></pre>
  
  <p>To be honest, I really don't know whether I coded this code correctly, as suggested.</p>