Created
December 23, 2019 15:46
-
-
Save 0x414c49/ec373dcb7910221d0638e9d38d18518c to your computer and use it in GitHub Desktop.
WeakReference.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Program | |
{ | |
static WeakReference _weakStringBuilder = | |
new WeakReference(new StringBuilder()); | |
static void Main(string[] args) | |
{ | |
if (_weakStringBuilder.IsAlive) | |
Console.WriteLine("Alive"); | |
GC.Collect(); | |
if (!_weakStringBuilder.IsAlive) | |
Console.WriteLine("Sade, it is colleced."); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment