Question Disposing and Returning

Pirahnaplant

Well-known member
Joined
Mar 29, 2009
Messages
75
Programming Experience
3-5
I have a function that returns a GraphicsPath. Is it possible to return and dispose of the Graphics path, or do I even need to dispose it?

This is what I tried.

VB.NET:
Public Function GP() As GraphicsPath
    Dim g As New GraphicsPath
    'Code goes here
    GP = g
    g.Dispose()
End Function

It doesn't work, it is returning a null GraphicsPath.
 
Last edited:
You have to dispose it when you are finished using it. The caller of your function is the consumer here and is responsible for this.
 
Back
Top