Copy value from one variable to another, not reference

Hi guys,

mayby a really stupid question:
How can I copy just the value of a variable to another variable?


After 3rd Assignment, variable int_b have the value “b” in the example above.

Is there a way to copy only the value “a” (in 2nd step) to the variabel int_b, so after 3rd step the variable int_b still has the value “a”?

Many thank,


It depends on type of variable. The following document helps you.


Copying the value is exactly what Assign does. There is no reference. It just takes the value of int_a and puts it into int_b.

In the above code, int_a should be b, and int_b should be a. Is this not the result you’re getting?

Hi Yoichi,
thanks for the hint.
I used a system.collections.generic.list type (obviously thats a reference type).
I changed it to an array type and now it works.


that was what I a also thought:)
But as I wrote, after 3rd Assignment, variable int_b becomes value “b”


Reference Types

A reference type stores a reference to its data. Reference types include the following:

  • String

That’s not what Reference Type means. Reference Type is about using a memory pointer, not about what happens when you assign one variable’s value to another. It doesn’t mean an assignment results in one variable pointing to another variable’s value. Each store their own value.


okay, damn it. That was my fault…

I guess the Locals panel confused me, I’m so sorry for this…

But nevertheless, the change from
system.collections.generic.list type to
array type
solved my problem!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.