p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   C# (http://p2p.wrox.com/forumdisplay.php?f=22)
-   -   what is inboxing (http://p2p.wrox.com/showthread.php?t=44823)

mokamurthy July 5th, 2006 04:15 AM

what is inboxing
hi all,
    i went to one interview. in that interview the person asked what is inboxing in c#,so plz give a mail for this question,nani.msn@gmail.com

anujrathi July 5th, 2006 06:46 AM

Hi friend,

First of all, u hav written wrong.
It is UnBoxing no InBoxing.

Lets see:

When u want to use a integer in any string or u want to convert any integer variable into string, U simply write

string s= 20.ToString();

This is called Boxing, means u hav a value type & u want a reference type then the Compiler create an object Box into which it places the value of value type.


int n=5;
//Create a box to hold the value of n
object obj=n;
//U know thar object is the datatype that can hold any data type

//Now u wnat to use ur integer value again, so u will unbox it
int m = (int)obj;

when u will do unboxing, Casting is must. If u will not do, thenm compiler will generate an error.

Anuj Rathi

All times are GMT -4. The time now is 06:10 AM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.