日期:2014-05-18  浏览次数:20740 次

关系数据长度
c# array Length函数可以算出数据长度,比如有一个整数数组长度为n, array.Length时间复杂度是O(1)还是O(n)?不知visual studio是怎么算这个值的。

------解决方案--------------------
How to resize an array in C#
In C#, arrays cannot be resized dynamically. One approach is to use System.Collections.ArrayList instead of a native array. Another (faster) solution is to re-allocate the array with a different size and to copy the contents of the old array to the new array. 

C#中array是固定长度的;所以array.Length的时间复杂度显然是O(1)的。
------解决方案--------------------
Array,因为固定内存它的Length必然是o(1)
不过不是所有的枚举类型都是如此。