How to modify the boxed value without creating a new object in C#?
问题 How to modify the boxed value without creating a new object in C#? E.g. if I have object o = 5; and I want to change the value of the boxed 5 to 6 , how can I do that? The o = 6; will create a new object on the heap and assign the reference to that object to the o . Are there any other ways to change the boxed value? 回答1: You can do the "boxing" yourself, than you can modify it. class Box { public int Value { get;set;} } This prevents the automatic boxing. If you define yourself an conversion