扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:维维编译 来源:天极开发 2007年11月13日
关键字:
public class CoOrdinate { public int x ; public int y; } |
var myCoOrd = new CoOrdinate{ x = 0, y= 0} ; |
var myCoOrd = new CoOrdinate(0, 0) ; |
List<string> animals = new List<string>(); animals.Add("monkey"); animals.Add("donkey"); animals.Add("cow"); animals.Add("dog"); animals.Add("cat"); |
List<string> animals = new List<string> {"monkey", "donkey", "cow", "dog", "cat" } ; |
class Program { delegate void DemoDelegate(); static void Main(string[] args) { DemoDelegate myDelegate = new DemoDelegate(SayHi); myDelegate(); } void SayHi() { Console.Writeline("Hiya!!") ; } } |
class Program { delegate void DemoDelegate(); static void Main(string[] args) { DemoDelegate myDelegate = delegate() { Console.Writeline("Hiya!!"); }; myDelegate(); } } |
class Program { delegate void DemoDelegate(); static void Main(string[] args) { DemoDelegate myDelegate = () => Console.WriteLine("Hiya!!") ; myDelegate(); } } |
ublic class CoOrdinate { public int x ; public int y; } |
// Use Object and collection initializers List<CoOrdinate> coords = ... ; |
var filteredCoords = from c in coords where x == 1 select (c.x, c.y) |
where x == 1 |
coords.where(c => c.x == 1) |
Expression<DemoDelegate> filter = () => Console.WriteLine("Hiya!!") ; |
濡傛灉鎮ㄩ潪甯歌揩鍒囩殑鎯充簡瑙T棰嗗煙鏈€鏂颁骇鍝佷笌鎶€鏈俊鎭紝閭d箞璁㈤槄鑷抽《缃戞妧鏈偖浠跺皢鏄偍鐨勬渶浣抽€斿緞涔嬩竴銆�