The following issue is puzzling me:
There are 2 ways of writing the code below:
....
Dim fnt as Font = New Font(...)
DrawString(myTe xt, fnt,...)
fnt.dispose().
or
DrawString(myTe xt, New Font(...),...)
The difference between both is that in the second case, there is no way to
explicitely dispose of the object (in the example, a Font object, but that
is purely circumstantial) . The basic issue is:
If an object is substantiated while passed a a parameter (as above), is it
inherently disposed by the called procedure (here: drawstring) or isn't it
at all?
The reason for this question is that I favor using the second way of coding,
because it much less verbose, but I am not sure about the consequences.
Can anybody shed some light on that? Thanks in advance.
There are 2 ways of writing the code below:
....
Dim fnt as Font = New Font(...)
DrawString(myTe xt, fnt,...)
fnt.dispose().
or
DrawString(myTe xt, New Font(...),...)
The difference between both is that in the second case, there is no way to
explicitely dispose of the object (in the example, a Font object, but that
is purely circumstantial) . The basic issue is:
If an object is substantiated while passed a a parameter (as above), is it
inherently disposed by the called procedure (here: drawstring) or isn't it
at all?
The reason for this question is that I favor using the second way of coding,
because it much less verbose, but I am not sure about the consequences.
Can anybody shed some light on that? Thanks in advance.
Comment