Advertisement
Guest User

Garbage Collection Example - CS

a guest
Jan 6th, 2012
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.94 KB | None | 0 0
  1. namespace GarbageCollection_CS
  2. {
  3.     using System;
  4.     using GarbageCollection_CLI;
  5.  
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             // Perform operations
  11.             var holder = PerformOperations();
  12.  
  13.             // Verify the object still exists in the holder
  14.             Console.WriteLine("Object exists within holder: {0}", holder.ObjectExists);
  15.  
  16.             // Wait for user exit
  17.             Console.WriteLine("Press any key to continue...");
  18.             Console.ReadKey();
  19.         }
  20.  
  21.         static ObjectHolder PerformOperations()
  22.         {
  23.             // Create an object
  24.             object o = new object();
  25.             Console.WriteLine("Object has been created.");
  26.  
  27.             // Pass the object to the C++/CLI code
  28.             ObjectHolder holder = new ObjectHolder(o);
  29.             Console.WriteLine("Holder has been created.");
  30.  
  31.             return holder;
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement