What is the difference between casting and boxing?

 Posted by Ddd on 1/21/2011 | Category: .NET Framework Interview questions | Views: 4933 | Points: 40

casting is the technique using which we convert data of one
type to data of another type.
It is like a main category of boxing.

boxing is a sub category of casting which deals with
converting a value type to a reference type.

1) double d=245.66;
//casting: conversion between 2 value types
int a=(int)d;

2) int f=200;

object z=f; //casting as well as boxing: conversion of a value type to a reference type.

Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Akiii on: 7/18/2011 | Points: 10
excellent question...


Login to post response