#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));
#endregion
#region 泛型类
Point<int> p = new Point<int>(10, 20);
Response.Write(p.ToString());
Point<float> pf = new Point<float>(12.2f, 23.2f);
Response.Write(pf.ToString());
#endregion
#region List<T>
//List<Person> list = new List<Person>();
//list.Add(new Person("张", "三"));
//list.Add(new Person("李","四"));
//list.Add(new Person("王", "五"));
//Response.Write(list[0].FirstName + list[0].LastName);
//Response.Write("<br/>-------------<br/>");
//for (int i = 0; i < list.Count; i++)
//{
// Response.Write(list[i].FirstName + list[i].LastName + "<br/>");
//}
#endregion
#region dictionary<T>
//Dictionary<string, Person> dic = new Dictionary<string, Person>();
//dic.Add("zhang", new Person("张", "三"));
//dic.Add("li", new Person("李", "四"));
//dic.Add("wang", new Person("王", "五"));
//Response.Write(dic["wang"].FirstName + dic["wang"].LastName+"<br/>");
//foreach (string str in dic.Keys)
//{
// Response.Write(str + "<br/>");
//}
//foreach (Person p in dic.Values)
//{
// Response.Write(p.FirstName + p.LastName + "<br/>");
//}
#endregion
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());
}
}
//public T Add<T>(T a, T b)
//{
// return a + b;
//}
public void Swap<T>(ref T a, ref T b)
{
T temp;
temp = a;
a = b;
b = temp;
}
//public void Swap(ref int a, ref int b)
//{
// int temp;
// temp = a;
// a = b;
// b = temp;
//}
//public void Swap(ref float a, ref float b)
//{
// float temp;
// temp = a;
// a = b;
// b = temp;
//}