I’m using Reflection to get all the fields of my class in c#, but now I want to get the GC Generation of each variable in my class. How can I do this?
CSkyclass
{
float time = 0;
}
Sky = new CSkyclass();
void GetGeneration()
{
FieldInfo[] FieldArray = typeof(CSkyclass).GetFields(flags);
foreach(System.Reflection.FieldInfo Field in FieldArray)
{
string name = Field.Name; //"time"
int g = GC.GetGeneration(name); //should = GC.GetGeneration(Sky.time);
}
}
Is this even possible?
Thanks
You’re trying to get the generation of the field’s value: