gcnew,

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • dogbert1793@yahoo.com

    #1

    gcnew,

    Hello,

    Does one need to delete pointers allocated with gcnew? Or does the
    garbage collector do it?

    I always though the garbage collector did it, but I saw this example
    today on MSDN:

    StreamReader^ sr = gcnew StreamReader( "TestFile.t xt" );
    try
    {
    String^ line;

    // Read and display lines from the file until the end of
    // the file is reached.
    while ( line = sr->ReadLine() )
    {
    Console::WriteL ine( line );
    }
    }
    finally
    {
    if ( sr )
    delete (IDisposable^)s r; // <-----DELETE HERE ???
    }

Working...