C# FAQ: Does CSharp support boxing

Microsoft .NET Framework, ASP.NET, Visual C# (CSharp, C Sharp, C-Sharp) Developer Training, Visual Studio


Jump to: navigation, search
CSharp-Online.NET:FAQs
edit

Does C# support boxing?

Both the .NET and Java systems support boxing and unboxing.

Boxing is the name of the process of automatically converting value types to objects by wrapping them with a reference type allocated on the heap. For example, this occurs when a method argument must be an object but an integer is supplied. In C#, structs allocated on the stack also need to be boxed and treated as objects.

Unboxing is the name of the process whereby objects are automatically converted to their corresponding value types. For example, in the Java language, this occurs when an instance of java.lang.Integer is converted to an int.


See also


Personal tools