.NET Versus COM
by Robert Gunion

Example 1:
(a)
void MyMethod()
{
int myInt;
myInt = 5;
} // (myInt doesn't need to be removed from memory manually)

(b)
void MyMethod()
{
    int * pmyInt = new int;
    *pmyInt = 5;
    delete pmyInt;  // must delete the pointer to prevent a memory leak!
}

Example 2:
struct MyValueType
{
    int myInt;
}
class MyReferenceType
{
    int myInt;
}
void MyMethod()
{
    MyValueType v;
    MyReferenceType r;
    v.myInt = 5;
    r.myInt = 5;
} // neither value nor reference type needs to be manually removed from memory!




1


