Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Getting a raw pointer to int from unmanaged C++ - Code

Getting a raw pointer to int from unmanaged C++ - Code

Scheduled Pinned Locked Moved C#
csharpc++data-structuresquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tomerland
    wrote on last edited by
    #1

    Dear developers, my managed C#-Code calls an unmanaged C++-Class-Method which allocates an array of integers (int *pInt = new int [5])and returns a reference to this array. How can I use this reference in my C#-Code without copying the values in the array. So far I didn't find any solution. Kind regards

    L 1 Reply Last reply
    0
    • T Tomerland

      Dear developers, my managed C#-Code calls an unmanaged C++-Class-Method which allocates an array of integers (int *pInt = new int [5])and returns a reference to this array. How can I use this reference in my C#-Code without copying the values in the array. So far I didn't find any solution. Kind regards

      L Offline
      L Offline
      Luc Pattyn
      wrote on last edited by
      #2

      Hi, AFAIK you can't. The only way I am aware of that avoids copying is by allocating the array on the managed side, pass it to the unmanaged side, and let it fill it there. The rationale is the managed metadata needs to be added to the raw data, and .NET is unable to do that for existing data. :)

      Luc Pattyn [Forum Guidelines] [My Articles]


      Voting for dummies? No thanks. X|


      T 1 Reply Last reply
      0
      • L Luc Pattyn

        Hi, AFAIK you can't. The only way I am aware of that avoids copying is by allocating the array on the managed side, pass it to the unmanaged side, and let it fill it there. The rationale is the managed metadata needs to be added to the raw data, and .NET is unable to do that for existing data. :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        Voting for dummies? No thanks. X|


        T Offline
        T Offline
        Tomerland
        wrote on last edited by
        #3

        seems reasonable what you say Thanks ! !

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups