Looking for c# Answers? Try Ask4KnowledgeBase
Looking for c# Keywords? Try Ask4Keywords

C# Language Assigning to a delegate by lambda


Lambdas can be used to create anonymous methods to assign to a delegate:

Func<int,int> addOne = x => x+1;

Note that the explicit declaration of type is required when creating a variable this way:

var addOne = x => x+1; // Does not work