Pastebin launched a little side project called HostCabi.net, check it out ;-)Don't like ads? PRO users don't see any ads ;-)
Guest

Garbage Collection Example - CS

By: a guest on Jan 6th, 2012  |  syntax: C#  |  size: 0.94 KB  |  hits: 46  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. }