1

The following piece of code written in C# and executed on Mono Droid, isn't working as expected.

    var strongRef = "abc";
    WeakReference weakRef = new WeakReference (strongRef);
    strongRef = null;
    System.GC.Collect (2,GCCollectionMode.Forced);
    System.Diagnostics.Debug.WriteLine ("Target:" + weakRef.Target + " IsAlive:" + weakRef.IsAlive);

Expected O/P: Target:null IsAlive:false

Actual O/P: Target:abc IsAlive:true

zafar
  • 1,965
  • 1
  • 15
  • 14

0 Answers0