try{StreamReader sr = File.OpenText("data.txt");
Console.WriteLine("The first line of this file is {0}", sr.ReadLine());
sr.Close();}catch(Exception e){print(e.Message);// throw new Exception();}//finally//{//}
垃圾回收(待补充)
正则表达式(待补充)
泛型相关
publicintIComparer<T>(){return0;}publicdelegateboolPredicate<T>(T item);struct Sk
{int ww;}publicstruct Nullable<T>where T:struct{}classTest<T,U>where U:structwhere T :new(){}publicclassSampleClass<T,U,V>where T : V
{}classBaseNode{}classBaseNodeGeneric<T>{}// concrete typeclassNodeConcrete<T>: BaseNode {}//closed constructed typeclassNodeClosed<T>: BaseNodeGeneric<int>{}//open constructed type classNodeOpen<T>: BaseNodeGeneric<T>{}publicdelegatevoidDel<T>(T item);publicstaticvoidNotify(int i){}
Del<int> m1 =newDel<int>(Notify);classStack<T>{
T[] items;int index;publicdelegatevoidStackDelegate(T[] items);}voidStart(){
Nullable<Sk> NI =newNullable<Sk>();int wo =IComparer<string>();
Predicate<int> bill =newPredicate<int>(wwwl);print(NI);print(wo);
SampleClass<int,string,int> gg;//约束相关 struct class unmanaged new() <基类名> <接口名> U//某些约束是互斥的。 所有值类型必须具有可访问的无参数构造函数。 struct 约束包含 new() 约束,且 new() 约束不能与 struct 约束结合使用。 unmanaged 约束包含 struct 约束。 unmanaged 约束不能与 struct 或 new() 约束结合使用。}
委托相关
publicclassPoint{publicPoint(int x,int y){
X = x;
Y = y;}publicint X;publicint Y;}privatevoidStart(){
Point[] points ={newPoint(100,200),newPoint(150,250),newPoint(250,375),newPoint(275,395),newPoint(500,650)};
Predicate<Point> predicate = FindPoints;
Point[] first = Array.FindAll(points, predicate);foreach(var item in first){print(string.Format("found: x={0},y={1}", item.X, item.Y));}}privateboolFindPoints(Point obj){return obj.X * obj.Y >100000;}