I have a function like the following:
Public Function testFunction(ByVal input_string As String) As String
Dim s As New StringBuilder()
Dim c As Char
For i As Integer = 0 To input_string.Length - 1
c = input_string.Chars(i)
s.Append(c)
Next
Return s.ToString
End Function
but I want know if it's better to explicitly destroy any object, like this:
Public Function testFunction(ByVal input_string As String) As String
Dim s As New StringBuilder()
Dim c As Char
For i As Integer = 0 To input_string.Length - 1
c = input_string.Chars(i)
s.Append(c)
Next
Dim t As String = s.ToString
s = Nothing
Return t
End Function
or just let the garbage collector do the job for us?
Both the above functions work, but I want only know the best practice for performance...
thank you