title: Convert array<Byte>^ data to const byte* data - C++/CLR
body: <p>I am trying to call a function in C from C# though c ++</p>
  
  <p>so basically C# -> C++ - >C</p>
  
  <p>In C#, I have byte[] bytes - which reads the information from the file. I am passing the byte array and the size to C++ .</p>
  
  <p>In C++ I get the byte array and the size but I am not able to convert to the specific data types.</p>
  
  <pre><code>void Image::OpenMemFile(array&lt;Byte&gt;^ data, unsigned int size)
  {
  
      Free();
      m_dataStream = data;
      Byte const* streamData = &amp;data[0];   // this is where it throws error 
           // Should I use marshaling here ? What call should that ;be ?
           hImage = ::OpenMemImage(streamData ,&amp;nbsp;size);
      modified = false;
  }
  
  // this is the function I&amp;nbsp;need to call 
  EXIVSIMPLE_API HIMAGE OpenMemImage(const&amp;nbsp;BYTE *data, unsigned int size)
  {
     // code
          imgWrap-&gt;image = Exiv2::ImageFactory::open(data, size);
  
  }
  </code></pre>
  
  <p>the C function it needs to call is </p>
  
  <pre><code>Image::AutoPtr ImageFactory::open(const byte* data, long size)
      {
        /// code
      }
  </code></pre>
  
  <p>I need to help in converting the byte array to const byte* . I realize I need to use Marshaling. Is there a specific function to marshal arrays in C++ ?</p>
  
  <p>Any help is appreciated.</p>
  
  <p>Thanks </p>