Showing posts with label difference between casting and boxing. Show all posts
Showing posts with label difference between casting and boxing. Show all posts

Tuesday 17 January 2012

difference between casting and boxing

What is the difference between casting and boxing?


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.

example:
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.