Developer, Former MVP, now at Microsoft - Best of 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, 2013
delegate bool SomeDelegate(int i);public void SomeMethod(){ SomeDelegate sd = new SomeDelegate(OtherMethod);// // other code here YetOneMore(sd);}private bool OtherMethod(int i){ return i > 2;}private void YetOneMore(SomeDelegate f){ bool res = f(5); Console.WriteLine(res.ToString());}
delegate bool SomeDelegate(int i);private void SomeMethod(){ SomeDelegate sd = delegate(int i){return i > 2;} ;// // other code here YetOneMore(sd);}private void YetOneMore(SomeDelegate f){ bool res = f(5); Console.WriteLine(b.ToString());}
delegate(int i){return i > 2;}
(int i) => { return i > 2;}
SomeDelegate sd = i => i > 2;