code_junkie

What does the '=>' syntax in C# mean?

Nov 12th, 2011
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. Func<Person, string> nameProjection = p => p.Name;
  2.  
  3. Func<Person, string> nameProjection = delegate (Person p) { return p.Name; };
  4.  
  5. x => x + 1
  6.  
  7. button.Click += new EventHandler((sender, e) => methodInfo.Invoke(null, new object[] { sender, e }));
  8.  
  9. delegate int del(int i);
  10. del myDelegate = x => x * x;
  11. int j = myDelegate(5); //j = 25
  12.  
  13. somevar.Find(delegate(int n)
  14. {
  15. if(n < 10)
  16. return n;
  17. });
  18.  
  19. somevar.Find(n => n < 10);
  20.  
  21. MyObjectReference => MyObjectReference.DoSomething()
  22.  
  23. MyCollection.Where(myobj => myobj.Age>10)
Add Comment
Please, Sign In to add comment