当添加大量元素时,System.Collections.Generic.List<T>它运行缓慢,因为当nums增加容量时,它必须复制所有元素.在C++中,这是固定的vector.reserve(n).我怎么能在C#中做到这一点?
System.Collections.Generic.List<T>
vector.reserve(n)
c# c++ using list stdvector
c# ×1
c++ ×1
list ×1
stdvector ×1
using ×1