LinkedList<int> bill =newLinkedList<int>();
bill.AddFirst(4);
bill.AddLast(1);
bill.AddLast(8);
bill.AddLast(4);
bill.AddLast(5);
LinkedList<int> bill2 =newLinkedList<int>();
bill2.AddFirst(5);
bill2.AddLast(0);
bill2.AddLast(1);
bill2.AddLast(8);
bill2.AddLast(4);
bill2.AddLast(5);
LinkedListNode<int> cur = bill.Find(8);
bill.AddBefore(cur,2);
bill.Remove(2);foreach(var item in bill){print(item);}
读《深入理解C#》第一遍一些实验(没精简)
//更简洁Person person =newPerson{ Name ="Tom", Age =9};print(person.Name);Go(new[]{1,2,3});//匿名类型var bill =new{ name ="sk", age =9};//表达式树Expression firstArg = Expression.Constant(2);Expression secondArg = Expression.Constant(3);Expressionadd= Expression.Add(firstArg, secondArg);
Func<int> compiled = Expression.Lambda<Func<int>>(add).Compile();print(compiled());
Expression<Func<int>> return5 =()=>5;var collection = Enumerable.Range(0,10);foreach(var item in collection){print(item);}//Cast和OfType语句ArrayList list =newArrayList{"First","Second","Third"};
IEnumerable<string> strings = list.Cast<string>();foreach(var item in strings){print(item);}ArrayList list =newArrayList{1,"not an int",2,3};
IEnumerable<int> ints = list.OfType<int>();foreach(var item in ints){print(item);}