本文介绍了它更快的名单,其中,T>卸下摆臂(T)或列表< T> .RemoveAt(int)方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
它更快的List.Remove(T)或.NET集合List.RemoveAt(int)方法?这是一个速度值类型和引用类型不同?
Is it faster the List.Remove(T) or List.RemoveAt(int) method in .NET collections? Is speed different for value types or reference types?
谢谢
阿尔贝托
推荐答案List.Remove(T)使用的IndexOf和RemoveAt(INT)在其实施。所以List.RemoveAt(INT)更快。
List.Remove(T) uses IndexOf and RemoveAt(int) in its implementation. So List.RemoveAt(int) is faster.
public bool Remove(T item) { int index = this.IndexOf(item); if (index >= 0) { this.RemoveAt(index); return true; } return false; }更多推荐
它更快的名单,其中,T>卸下摆臂(T)或列表< T> .RemoveAt(int)方法?
发布评论