In the example below, will the returned pen
be destroyed(disposed) or not?
' VB'
Public Function GetPen() As System.Drawing.Pen
Using pen As New System.Drawing.Pen(_Color, _Width)
pen.DashStyle = _DashStyle
Return pen
End Using
End Function
// C#
public System.Drawing.Pen GetPen()
{
using (System.Drawing.Pen pen = new System.Drawing.Pen(_Color, _Width))
{
pen.DashStyle = _DashStyle;
return pen;
}
}
[EDIT]
Just one more precision... Is the Pen object sent to the caller of GetPen by reference or 'cloned' like a structure? I know, this is a class, but with GDI objects I am never sure...
Will it be destroyed(disposed) the pen
created in GetPen()
when the external method will Dispose its pen
obtained with GetPen()
?