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 reflection
C# makes it easy to create large graphs of objects connected by their fields. The larger this graph grows, the more complex it is to deal with objects in the graph. It’s hard to look at code or set a breakpoint in a debugger and get an intuitive sense of all these connections. So today we’ll write a small tool to visualize an object graph!
Today’s article looks at the IL2CPP and C++ compiler output for a variety of C# language features. Do you want to know what happens when you use them? Read on to find out!
LINQ expressions aren’t the same thing as LINQ queries. They’re more like reflection for the syntax of C# itself. It’s a fascinating—and powerful—area of the language and I’ll be exploring it a little in today’s article.
StrangeIoC is a library that can help you build your Unity app with a “pure code” approach. Today’s article addresses one common concern with using StrangeIoC- it uses a lot of reflection. As we know, that’s really slow in Unity. StrangeIoC tries to work around it by letting you control when the reflection takes place so you can put it on a loading screen or some other convenient place. Today’s article finds out just how slow the reflection is to determine if this is really a valid reason to not use StrangeIoC (or other dependency injection frameworks). Read on to find out!
Reflection allows you to introspect your code at runtime. You can do very dynamic things like call functions by their name as a string. As such, it’s a really powerful tool when you code needs to be more flexible. Unfortunately, it’s slow. Really slow. Today’s article puts it up against regular, non-reflection code to show the difference in speed. It’ll also walk you through reflection in C# in case you’ve never used it before. Read on to learn more about reflection in Unity!