Let's say I have a primitive value that I need to assign to some field using reflection. I know for sure that the field has the same primitive value type.
Is it possible to somehow set this value without boxing?
void SetFloat(object o, string name, float val)
{
var type = o.GetType();
var fld = type.GetField(name);
fld.SetValue(o, val );
}
PS This is not about latency indeed, it is about the possible pressure of GK. I use Unity3D, which uses the old version of Mono veeeery, which in turn uses a very sub-optimal GC implementation. Each additional memory allocation is calculated: (
PPS I am building my own interpreter in C #, avoiding reflection seems almost impossible.
source
share