-
Notifications
You must be signed in to change notification settings - Fork 1
Boxing
Mario Gutierrez edited this page Jan 7, 2017
·
1 revision
Every time you assign a ValueType
to a ReferenceType
, e.g.,
int f = 5;
object oa = f;
C# does a 'box' operation: allocates an object on the heap and moves the value from the stack to the new object.
C# does an 'unbox' operation to do the inverse, and requires casting:
int g = (int)oa;
This is very inefficient speed-wise and memory-wise.
- Abstract Classes
- Access Modifiers
- Anonymous Methods
- Anonymous Types
- Arrays
- Attributes
- Console I/O
- Constructors
- Const Fields
- Delegates
- Enums
- Exceptions
- Extension Methods
- File IO
- Generics
- Interfaces
- Iterators
- LINQ
- Main
- Null Operators
- Parameters
- Polymorphism
- Virtual Functions
- Reflection
- Serialization
- Strings
- Value Types
- "Base" Keyword
- "Is" and "As"
- "Sealed" Keyword
- nameof expression