In last week’s tips for using collections like
List<T>, we saw how struct types are sometimes boxed resulting in GC allocations. This week we’ll see how to avoid boxing and learn some of the clever tricks that .NET collection types use to make this possible.
Posts Tagged boxing
Collection types like
Dictionary<TKey, TValue> are fundamental tools in C#. Sadly, I keep seeing the same misuses of them in codebase after codebase. Today we’ll look at the top 5 problems and learn how to easily avoid them!
Value types like
int, structs, and enums seem simple, but much of what we think we know about them just isn’t true. This article explores how value types actually work in C# and uses that knowledge to improve how they’re implemented in the C++ scripting system.
The GitHub project is closing in on supporting all the “must have” features. Today’s article tackles “boxing” and “unboxing” so our C++ game code will be able to convert types like
int into an
object and then convert an
object back into an
int. Usually we want to avoid this because it creates garbage for the GC to later collect and ruins type safety, but sometimes an API like
Debug.Log insists that we pass it an
object. Read on to see how to use boxing and unboxing in C++!