Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumC#reflection and attributesSingle-choice MCQ

Using reflection to set a private readonly instance field after construction: which statement is accurate about whether it works?

class Box { public readonly int N = 1; } var box = new Box(); var f = typeof(Box).GetField("N"); f.SetValue(box, 42); Console.WriteLine(box.N);