2
Reply

What is concept of Boxing and Unboxing ?

18y
5.2k
0
Reply

    Boxing and Unboxing are quite helpful, when the type of the object you need are not definitive when creating it, and the caller can type cast it based on the method call.

    Ex:

    object o = GivemeResponse(params);

    MyResponse  aresp = (MyResponse) o;

    Boxing is conversion (implicit) of value type to refference type

    e.g.

    object box;

    box=1;

    Unboxing is explicit conversion of refference type to value type

    e.g.

    int i=3;

    i=(int)box;