Skip to main content

Memory model checkpoint

Challenge on lesson: Checkpoint: memory model

CHALLENGE
Difficulty: advanced+25 XP

Implement static (int copiedX, int aliasedY) AliasVsCopy(). Inside: create a struct S { public int X; } with X=1, copy it to a second local and set the copy's X=2 (original must stay 1); then create an array int[] a = {5}, take a ref local ref int r = ref a[0], set r=7. Return (original struct X, a[0]).

Back to lesson: Checkpoint: memory model