將一個數組反轉通過算法去實現雖然可以簡化但是如果實際項目中使用還有一種更快速的辦法簡單有效
public class ReverseList<T> : IList<T>
{
private IList<T> _list;
public ReverseList(IList<T> list)
{
this_list = list;
}
public T this[int index]
{
get
{
return _list[thisCount index];
}
}
}
//test
DateTime t = DateTimeNow;
IList<int> list = new List<int>();
for (int i = ; i <= * ; i++)
{
listAdd(i);
}
DateTime t = DateTimeNow;
list = new ReverseList<int>(list);
DateTime t = DateTimeNow;
ConsoleWriteLine(Create Array:{} ((TimeSpan)(t t))TotalMilliseconds);
ConsoleWriteLine(Reverse Array:{} ((TimeSpan)(t t))TotalMilliseconds);
ConsoleWriteLine(list[]);
ConsoleReadKey();
From:http://tw.wingwit.com/Article/program/net/201311/12694.html