4
votes
1answer
375 views

Is there delegate in Java 8 (JDK8)?

Is there delegate in Java 8 ? If No , How we have lambda expressions in JDK 8 without delegates ? What is Method References ? Is this the same as delegate? Method References Thanks
1
vote
1answer
33 views

How do I construct a delegate and pass it as a parameter to be used in a lambda expression

I am refactoring some code the original statement was var deleteList = new List<FilterParameter>(); foreach (FilterParameter param in FilterParameters) { if (memlist.All(x => ...
2
votes
2answers
2k views

C# Lambda Functions: returning data

Am I missing something or is it not possible to return a value from a lambda function such as.. Object test = () => { return new Object(); }; or string test = () => { return "hello"; }; I ...
3
votes
1answer
606 views

Assign a function delegate that returns an anonymous type to a variable

The code below is valid: IEnumerable<SomeThing> things = ...; // map type SomeThing to a new anonymous type, resulting in a strongly typed // sequence based on an anon type var newList = ...
2
votes
3answers
489 views

Delegate in a where clause

I can define a delegate and write the query like this. Func<string, bool> filter = s => s.Length == 5; IEnumerable<string> query = names.Where(filter) ...
1
vote
3answers
338 views

SortedList with string as index and function pointer or delegate as value? And Calling Functions by strings?

I'm not familiar with delegates and lambdas but at this moment, I have to do these two things: One of them is: I need to pass the function to SortedList. I don't know how it can be done. Why I ...
10
votes
2answers
3k views

Are lambda functions faster than delegates/anonymous functions?

I assumed lambda functions, delegates and anonymous functions with the same body would have the same "speed", however, running the following simple program: static void Main(string[] args) { ...
3
votes
2answers
102 views

Dynamically Generating Buttons that Call a Lambda Function — Variable Scope

I have a situation where I have someFunction(int), and I need to generate programmatically n buttons that will call it. What this means is that I want to create buttons B1, B2, ... Bn that call ...
5
votes
2answers
3k views

C#: create a do-nothing Action on class instantiation [duplicate]

I have a class that the user can pass an Action into (or not). public class FooClass<T> : BaseClass<T> { public FooClass() : this((o) => ()) //This doesn't work... { ...