Returns the current generation number of the target of a weak reference.
using System; public class MainClass { static void Main() { MainClass myGCCol = new MainClass(); WeakReference wkref = new WeakReference(myGCCol); myGCCol = null; Console.WriteLine("The WeakReference to the object is in generation: {0}", GC.GetGeneration(wkref)); GC.Collect(); } }