I have a list as
string[] names = new string[20000];
I need to clear the items in this list.
I tried names.clear()
, names.Dispose()
but none seems to be appropriate.
What shud I have used ?
Array.Clear(names, 0, names.Length);
你试过这个吗?
好吧,我认为最好的方法是将数组实际更改为List
如果列表是您需要的:
var names = new List<string>();
然后,您可以使用清除它names.Clear()
那是一个array
不是list
。尝试Array.Clear
Array.Clear(names, 0, names.Length);
怎么样
names = new string[20000];