Team LiB
Previous Section Next Section

Heap and Stack Memory

Within virtual memory, there are two very important areas of memory:

The following example shows the use of heap and stack memory.

Code Example: Heap and Stack Memory
Start example

using System;

namespace Client.Chapter_7___Memory_Management
{
      class HeapandStackMemory
      {
            static void Main(string[] args)
            {
                  //Creates a reference type
                  MyClass ThisClass = new MyClass();
            }
      }
      public class MyClass
      {
            public int MyInt;
            private long MyLong;
            public void DoSomething()
            {
                  Console.WriteLine(MyInt);
                  Console.WriteLine(MyLong);
            }
      }
}
End example

Team LiB
Previous Section Next Section