开发者

vb.net: clearing all contents of string array

开发者 https://www.devze.com 2022-12-09 13:13 出处:网络
i have this: Dim split As String() = temp_string.Split(\",\") \'\'#fe开发者_开发问答ed all info into global variables

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号