Thread: How can I pass int arrays from C++ to C#?

  1. #1
    Vince
    Guest

    How can I pass int arrays from C++ to C#?

    Hi,

    Currently I have some code in C++ that makes callbacks to C# code. I pass in a function pointer (or a delegate in C#-speak) of a C# method into C++ and C++ just calls it whenever it needs to. Everything was fine until C++ had to pass an int array back to C# through the callback as an argument.

    C# only sees the first element in the array and thinks that the array is of size 1. Is there any way to fix this? Any ideas?

    Thanks in advance,

    Vince

    =============
    p.s. - sorry for double-posting... this is about C++/C# conversion and I wasn't sure if one board was better than the other for this question so I put it in both... could I suggest the creation of a board on the interoperations between C, C++ and C#? Or is the community for such a topic still too small to sustain a forum?

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Vince
    Guest

    Unhappy

    Dude, at least read my message... before accusing me of cross-posting

    I did apologize for that already!!! I'm disappointed that you bothered to post to state the obvious without even reading my messages thoroughly

    I don't know which community I should really seek help from since this bridges C++ and C#...

    fine i'll do it again: I'm sorry for cross-posting and I just realized that many of you may read all the forums, but there are occasions where I don't know whether this is an issue for C++ experts or C# gurus.

    And again I'd like to suggest the possibility of a forum for interoperability issues.

    Thanks

    Vince

  4. #4
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,130
    Is it managed or unmanaged C++ ?
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  5. #5
    Vince
    Guest

    Unhappy

    It's unmanaged C++.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Working with random like dice
    By SebastionV3 in forum C++ Programming
    Replies: 10
    Last Post: 05-26-2006, 09:16 PM
  2. Game Won't Compile
    By jothesmo in forum C++ Programming
    Replies: 2
    Last Post: 04-01-2006, 04:24 PM
  3. Replies: 2
    Last Post: 03-24-2006, 08:36 PM
  4. Replies: 4
    Last Post: 11-23-2003, 07:15 AM
  5. How do you search & sort an array?
    By sketchit in forum C Programming
    Replies: 30
    Last Post: 11-03-2001, 05:26 PM