Making a value type behave as a reference type using Expression>

后端 未结 3 1671
失恋的感觉
失恋的感觉 2021-01-21 02:41

We know that int is a value type and so the following makes sense:

int x = 3;
int y = x;
y = 5;
Console.WriteLine(x); //says 3. 

Now, here is a

3条回答
  •  走了就别回头了
    2021-01-21 03:03

    Integers in .NET are immutable. I'm not sure what problem you're trying to solve with this issue. Have you considered creating a class which has a property which "wraps" the integer? That class would be a reference types and what you're trying to achieve would not require any "magic" utility classes - just normal C# reference-type behavior.

提交回复
热议问题