#region 泛型方法
int a = 10;
int b = 20;
this.Swap(ref a, ref b);
//Swap(ref a,ref b);
Response.Write(string.Format("a:{0};b:{1}", a, b));
public void Swap<T>(ref T a, ref T b)
{
T temp;
temp = a;
a = b;
b = temp;
}
#endregion
用Queue
Queue<int> qu = new Queue<int>();
for (int i = 0; i < 10; i++){
qu.Enqueue(i);
}
for (int i = 0; i < 10; i++){
Response.Write(qu.Dequeue().ToString());
}
Response.Write("<br/>==================<br/>");
Stack<int> st = new Stack<int>();
for (int i = 0; i < 10; i++){
st.Push(i);
}
for (int i = 0; i < 10; i++){
Response.Write(st.Pop().ToString());
}