| class TestUsing:IDisposable { public void Dispose() { Console.WriteLine("Dispose"); } public void Method() { Console.WriteLine("Do a method"); } } |
| using(TestUsing tu=new TestUsing()) { tu.Method(); } |
| expression as type |
| expression is type ? (type)expression : (type)null |
| object [] arr=new object[2]; arr[0]=123; arr[1]="test"; foreach(object o in arr) { string s=(string)o; Console.WriteLine(s); } |
| object [] arr=new object[2]; arr[0]=123; arr[1]="test"; for(int i=0;i<arr.Length;i++) { string s=arr[i] as string; if(s!=null)Console.WriteLine(i+":"+s); } |