vb.net: clearing all contents of string array
i have this:
Dim split As String() = temp_string.Split(",")
''#fe开发者_开发问答ed all info into global variables
patient_id = split(0)
doc_name = split(1)
lot__no = split(2)
patient_name = split(3)
how do i clear all the contents of split() ?
Array.Clear(split, 0, split.Length)
ReDim split(-1)
No need to do anything. The garbage collector will do its jobs clearing the variable. Explicitly set every variable to nothing will slow down your application.
You can always set it to Nothing
which will clear the reference. Then the garbage collector will take care of the rest when it finds that to be a good idea.
split = Nothing
However, if this is a local variable of a method you would typically not need to worry about this, the array will be available for garbage collection as soon as it goes out of scope.
精彩评论