p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/)
-   C# (http://p2p.wrox.com/c-22/)
-   -   what is inboxing (http://p2p.wrox.com/c/44823-what-inboxing.html)

mokamurthy July 5th, 2006 05: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 07: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.

eg.

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.

Regards,
Anuj Rathi


Antonio153 December 26th, 2018 01:14 AM

Quote:

Originally Posted by mokamurthy (Post 44823)
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

When the CLR boxes a value type, it wraps the value inside a System.Object and stores it on the managed heap. Unboxing extracts the value type from the object. Boxing is implicit; unboxing is explicit. ... The following examples illustrate how boxing is used in C# 9apps


All times are GMT -4. The time now is 06:17 PM.

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