I have a structure something like this
struct MyStructure
:IFoo
{
}
and a method like this:
public BarThisFoo(IFoo a)
{
}
my question is does passing the structure into that method “box” the structure, thus causing a garbage allocation?
Addendum:
Before anyone says it, garbage collection is not free in this application, it’s actually very sensitive to garbage collections, so allocation free code is important.
Yes, it does. Boxing occurs whenever you convert from:
System.ValueTypereferenceSystem.EnumreferenceThis is case III, obviously. You can read a more thorough example here.