Why do we need boxing and unboxing in C#?
问题 Why do we need boxing and unboxing in C#? I know what boxing and unboxing is, but I can\'t comprehend the real use of it. Why and where should I use it? short s = 25; object objshort = s; //Boxing short anothershort = (short)objshort; //Unboxing 回答1: Why To have a unified type system and allow value types to have a completely different representation of their underlying data from the way that reference types represent their underlying data (e.g., an int is just a bucket of thirty-two bits