If I set a breakpoint on all four lines within the curly brackets in
VS2005, the 'delete str' breakpoint is always removed and the line
itself is removed from the code.
Why is not possible to call delete on a String^ ref type like it is
for other ref handles? Would it be because the String type has no
protected member called Dispose?
{
String^ str = gcnew String( messageText );
delete str;
IO::StreamReader^ rdr = gcnew IO::StreamReader("d:\\done.txt");
delete rdr;
}
Many thanks,
Duncan
Ben Voigt [C++ MVP] - 08 Nov 2007 15:40 GMT
> If I set a breakpoint on all four lines within the curly brackets in
> VS2005, the 'delete str' breakpoint is always removed and the line
[quoted text clipped - 3 lines]
> for other ref handles? Would it be because the String type has no
> protected member called Dispose?
That is my understanding. There's some information at
http://msdn2.microsoft.com/en-us/library/ms177197(VS.80).aspx but it doesn't
come right out and say that the delete keyword calls IDisposable::Dispose
when invoked on an imported managed type.
> {
> String^ str = gcnew String( messageText );
[quoted text clipped - 7 lines]
>
> Duncan
Mark Salsbery [MVP] - 08 Nov 2007 17:08 GMT
> If I set a breakpoint on all four lines within the curly brackets in
> VS2005, the 'delete str' breakpoint is always removed and the line
[quoted text clipped - 5 lines]
>Would it be because the String type has no
> protected member called Dispose?
Yes System::String is not a disposable class (no IDisposable interface).
The StreamReader class, however, IS disposable :)
Mark

Signature
Mark Salsbery
Microsoft MVP - Visual C++
> {
> String^ str = gcnew String( messageText );
[quoted text clipped - 7 lines]
>
> Duncan