static void Main()
        {
            MemoryObj mObj = new MemoryObj();

            DisposingMemoryObject(mObj);
            Console.WriteLine("Object still alive");
            mObj.arr[1] = 20000;
            Console.ReadKey();
        }
示例#2
0
        static void Main(string[] args)
        {
            using (MemoryObj obj = new MemoryObj())
            {
                obj.arr[0] = 1000;
                System.GC.SuppressFinalize(obj);
            }
            GC.Collect();

            Console.ReadKey();
        }
 private static void DisposingMemoryObject(MemoryObj mObj)
 {
     mObj.arr[0] = 10000;
 }