Experts Exchange connects you with the people and services you need so you can get back to work.
They are not used very often, except by programmers that come from a background
object o = 32; // 32 is an integer (type), so it gets boxed into a reference type to make the assignment work
Open in new window
int i = (int)o;
ArrayList a = new ArrayList();
a.Add(32); // since an ArrayList holds items of type object, the int is boxed into a reference type before it is added
string text1 = "x";
bool res = int.TryParse(text1, out num1);
Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.
One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.
Boxing and unboxing occur implicitely when you pass a value object by reference
There is no boxing of a value type when it is passed by reference.
there are few reasons to treat a value object, such as an Integer, through an Object variable. Usually, you know if a variable will be an Integer, a Double or a Date, and there is no need to treat it as an object.
and reference objects do not implicate boxing.
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
From novice to tech pro — start learning today.
Premium members can enroll in this course at no extra cost.