473,499 Members | 1,589 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Do managed strings have a deterministic destructor?

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

Nov 8 '07 #1
2 1037

"Duncan Smith" <DS********@googlemail.comwrote in message
news:11**********************@t8g2000prg.googlegro ups.com...
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?
That is my understanding. There's some information at
http://msdn2.microsoft.com/en-us/lib...97(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 );
delete str;

IO::StreamReader^ rdr = gcnew IO::StreamReader("d:\\done.txt");
delete rdr;
}

Many thanks,

Duncan

Nov 8 '07 #2
"Duncan Smith" <DS********@googlemail.comwrote in message
news:11**********************@t8g2000prg.googlegro ups.com...
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?

Yes System::String is not a disposable class (no IDisposable interface).

The StreamReader class, however, IS disposable :)

Mark

--
Mark Salsbery
Microsoft MVP - Visual C++
>
{
String^ str = gcnew String( messageText );
delete str;

IO::StreamReader^ rdr = gcnew IO::StreamReader("d:\\done.txt");
delete rdr;
}

Many thanks,

Duncan
Nov 8 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1261
by: Slawomir Lisznianski | last post by:
Do ref classes indeed support instantiation on the stack? Similarly, can native classes be instantiated on gc heap? When you try to have a ref class instance on the stack, you'll get: R :...
11
1933
by: Lloyd Dupont | last post by:
(not I use 2.0, so new return a "normal" pointer and gcnew return a managed one, my question below regarding new concern plain standart C++ allocator) - if I use the default new operator, are all...
9
1321
by: Peter Oliphant | last post by:
I would assume in the following that 'instance' being set to 'nullptr' should cause the instance of myClass that was created to no longer have any pointers pointing to it, and therefore be...
4
2049
by: Maxwell | last post by:
Hello, Newbie question here for disposing of unmanaged resources in MC++.NET. I have a managed VS.NET 2003 MC++ wrapper class that wraps a unmanaged C++ dll. What I am trying to figure out is...
5
7036
by: Michael D. Reed | last post by:
I have legacy DLL code written in C++ that is essentially C code, an implementation of a set of formulas used in our industry. There are no DB or GUI interfaces, just exposed methods. I would...
9
2986
by: plahey | last post by:
I have been dabbling in Python for a while now. One of the things that really appeals to me is that I can seem to be able to use C++-style RAII idioms to deal with resource management issues. ...
3
1155
by: Greg | last post by:
In the following example, where is "n" allocated (e.g. managed heap?) ? public ref class N { .... .... } main() {
16
8754
by: pkoniusz | last post by:
Hello everybody, Been just thinking how actually one could convert the following unmanaged code to the managed C++: struct JustAnExample { char value1; int value2; // etc ....
25
2977
by: Koliber (js) | last post by:
sorry for my not perfect english i am really f&*ckin angry in this common pattern about dispose: ////////////////////////////////////////////////////////// Public class...
0
7178
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7223
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
5475
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4919
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4602
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3103
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3094
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
665
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.