Practice ยท 1 of 3
Copy or Alias?
CHALLENGE
Difficulty: intermediate+25 XP
Implement two small types and a probe โ the test asserts what each assignment did:
``csharp
public struct ValuePoint { public int X; } /* value: copies */
public sealed class RefPoint { public int X; } /* reference: aliases */
/* increments X and returns the (copied) struct โ the caller's copy
must NOT be affected */
static ValuePoint BumpValue(ValuePoint p);
/* increments X through the reference โ the caller's object MUST be
affected, and the same instance is returned */
static RefPoint BumpRef(RefPoint p);
``
Press Submit to check your solution.
Back to lesson: Practice: Semantics Gym