locked
how to modify the value type data which is parameter passed into function?

    Question

  • If I want to modify the value type data ,which is passed into function as paramter,in function,what can I do?

    I am intent to box the data in order to consider it as a ref type,but it is readonly.

    Now I have to pass it out as a return value;

    Saturday, April 28, 2012 3:40 AM

Answers

All replies

  • Could you please describe your question in more detail?

    You can modify the value type data just as what you did in traditional c++ application.

    For example,  You create a winrt lib and define follow function:

    public bool func1(int* param1);

    Then you can modify the value of param1 in func1. You can call func1 in your  C# metro style application:

    func1(out param1);

    Best Regards,

    Han Xia


    Saturday, April 28, 2012 5:26 AM
    Moderator
  • Readonly Variable or Object doesn't have set property..

    So ,you can't change it's value.

    It never be as reference type...

    You can't change value type of object at runtime


    Please, If answer match your requirement then set mark as answer

    Saturday, April 28, 2012 6:13 AM
  • Hello,

    Please describe your question detail.

    Do you want to use reference to in C++/CX? if so, you can use % instead of & in native C++. Please check this document.
    http://msdn.microsoft.com/en-us/library/windows/apps/br212455.aspx

    Best regards,
    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Jesse Jiang Monday, May 7, 2012 2:16 AM
    Monday, April 30, 2012 7:38 AM