locked
How to pass a platform::Collections::map by reference ?

    Question

  • Hi,

    I want to pass the Platform :: Collections :: map by reference to a function. Intent is that i will have key value pairs inserted into the map in the function being called and i would need a reference to the updated map from the function scope where i call it from.

    Thanks!

    Monday, April 21, 2014 12:55 PM

Answers

  • All ref class variables including those of type Platform::Collections::Map, Vector, etc ARE references, so if you modify the object's state in a function, that change is visible back at the call site because it's the same object.
    Friday, April 25, 2014 12:12 AM

All replies

  • Please show the function signature.

    Matt Small - Microsoft Escalation Engineer - Forum Moderator
    If my reply answers your question, please mark this post as answered.

    NOTE: If I ask for code, please provide something that I can drop directly into a project and run (including XAML), or an actual application project. I'm trying to help a lot of people, so I don't have time to figure out weird snippets with undefined objects and unknown namespaces.

    Monday, April 21, 2014 7:21 PM
    Moderator
  • All ref class variables including those of type Platform::Collections::Map, Vector, etc ARE references, so if you modify the object's state in a function, that change is visible back at the call site because it's the same object.
    Friday, April 25, 2014 12:12 AM
  • Thanks all !! It works !!
    Friday, April 25, 2014 3:37 AM