开发者

How to empty a List<T>?

开发者 https://www.devze.com 2022-12-12 06:43 出处:网络
I have a list: List<int> MyList = new List<int>(); I added 10 int values in it: for{i=1;i<10;i++}

I have a list:

List<int> MyList = new List<int>();

I added 10 int values in it:

for{i=1;i<10;i++}
    MyList.Add(1);

Can I make it empty in one shot, rather than us开发者_开发技巧ing

  • 10 times iteration of Remove function
  • RemoveAll method with a Predicate<(Of <(T>)>) generic delegate.


MyList.Clear();

0

精彩评论

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