none
Copy int as a value type and not reference type? RRS feed

  • Question

  • Hello,

    Is there a syntax to copy a int aa = 4 into another int ff as a valuetype?

    I don't to have a pointer or silmiliar when you make any changes in the value.

    Thank you!
    • Edited by Sakura Data Thursday, June 20, 2019 9:00 AM
    Thursday, June 20, 2019 9:00 AM

All replies

  • This is the way struct types, such as 'int', already work in C#.  When you assign from one int to another, a copy is made.

    Convert between VB, C#, C++, & Java (http://www.tangiblesoftwaresolutions.com)
    Instant C# - VB to C# Converter
    Instant VB - C# to VB Converter

    Thursday, June 20, 2019 12:57 PM
  • Hi

    Is your problem solved? If so, please post "Mark as answer" to the appropriate answer, so that it will help other members to find the solution quickly if they face a similar issue.

    Best Regards,

    Jack


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, June 25, 2019 8:55 AM
    Moderator
  • You can achieve this using Structs. refer @http://www.albahari.com/valuevsreftypes.aspx

    • Proposed as answer by AR_01 Friday, July 5, 2019 5:16 PM
    Friday, July 5, 2019 4:59 PM
  • You can achieve this using Structs. refer @http://www.albahari.com/valuevsreftypes.aspx

    But 'int' is already a value type (struct), so it already behaves in the way the user wanted.


    Convert between VB, C#, C++, & Java (http://www.tangiblesoftwaresolutions.com)
    Instant C# - VB to C# Converter
    Instant VB - C# to VB Converter

    Friday, July 5, 2019 7:54 PM