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.
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.
No comments:
Post a Comment