tagged [func]
Is Func<in T, out TResult> appropriate to use as a ctor arg when applying Dependency Injection?
Is Func appropriate to use as a ctor arg when applying Dependency Injection? Example: ``` public class BusinessTransactionFactory where T : IBusinessTransaction { readonly Func _createTransaction; ...
- Modified
- 28 Nov at 19:18
Why Func<T,bool> instead of Predicate<T>?
Why Func instead of Predicate? This is just a curiosity question I was wondering if anyone had a good answer to: In the .NET Framework Class Library we have for example these two methods: ``` public s...
Extension method that extends T - bad practice?
Extension method that extends T - bad practice? I've read that it is usually bad practice to extend System.Object, which I do agree with. I am curious, however, if the following would be considered a ...
- Modified
- 14 Apr at 22:37
Why is Action/Func better than a regular Method in .Net?
Why is Action/Func better than a regular Method in .Net? I much prefer using an Action or a Func if I need a quick reusable piece of code, however others on my team don't like them or understand them....
The request message was already sent. Cannot send the same request message multiple times
The request message was already sent. Cannot send the same request message multiple times Is there anything wrong with my code here? I keep getting this error: > System.InvalidOperationException: The ...
- Modified
- 30 Jul at 21:36
use Func<> (or Action<>) or create own delegate?
use Func (or Action) or create own delegate? Which one is better in, say, parameter type in a method (not related to LINQ). Apparently Func is better since it's simpler, more descriptive, and if every...
- Modified
- 16 Dec at 08:5
Convert Func<T, String> to Func<T, bool>
Convert Func to Func I think my mind is exploding trying to figure out Funcs... If this makes no sense, I apologize, right now it make sense to me but its been a long day already .... 1) Assuming you ...
How do I declare a Func Delegate which returns a Func Delegate of the same type?
How do I declare a Func Delegate which returns a Func Delegate of the same type? I'd like to write a method which does some work and finally returns another method with the same signature as the origi...
converting a .net Func<T> to a .net Expression<Func<T>>
converting a .net Func to a .net Expression> Going from a lambda to an Expression is easy using a method call... But I would like to turn the Func in to an expression, o
- Modified
- 8 Nov at 21:11
Lambda\Anonymous Function as a parameter
Lambda\Anonymous Function as a parameter I'm a very new to C#. Just playing around with it. Not for a real purpose. Is it possible to use a REAL anonymous funct
Can someone explain what the C# "Func<T,T>" does?
Can someone explain what the C# "Func" does? I'm reading the Pro MVC 2 book, and there is an example of creating an extension method for the HtmlHelper class. Here the code example: And here is an exa...
Using FluentValidation's WithMessage method with a list of named parameters
Using FluentValidation's WithMessage method with a list of named parameters I am using FluentValidation and I want to format a message with some of the object's properties value. The problem is I have...
- Modified
- 5 Jan at 00:40
How can I pass in a func with a generic type parameter?
How can I pass in a func with a generic type parameter? I like to send a generic type converter function to a method but I can't figure out how to do it. Here's invalid syntax that explains what I lik...
Assigning a Func to an Expression and vice versa
Assigning a Func to an Expression and vice versa I was tampering with Expressions and I got confused at some points 1. We can assign same LamdaExpression to both Expression and/or Func. But we cannot ...
- Modified
- 5 Jan at 19:32
Encapsulating Action<T> and Func<T>?
Encapsulating Action and Func? I'm trying to make a design for some sort of IExecutable interface. I will not get into details, but the point is that I have several Actions that need to be executed fr...
- Modified
- 25 Nov at 17:15
How do you use Func<> and Action<> when designing applications?
How do you use Func and Action when designing applications? All the examples I can find about Func and Action are as in the one below where you see they technically work but I would like to see them u...
- Modified
- 8 Oct at 12:7
How to invoke Expression<Func<Entity, bool>> against a collection
How to invoke Expression> against a collection I have an interface that defines a repository from the Repository pattern: I've implemented it against Entity Framework: ``` class EntityFrameworkReposit...
- Modified
- 24 Sep at 03:51
Using LINQ's Zip with a closure that doesn't return a value
Using LINQ's Zip with a closure that doesn't return a value Disclaimer: this question is driven by my personal curiosity more than an actual need to accomplish something. So my example is going to be ...
C#: Elegant way to wrap method calls
C#: Elegant way to wrap method calls Apologies for the fairly ambiguous title but what I'm trying to achieve is probably better stated in code. I have a WCF client. When I'm calling methods I would li...
Why is Func<> created from Expression<Func<>> slower than Func<> declared directly?
Why is Func created from Expression> slower than Func declared directly? Why is a `Func` created from an `Expression>` via .Compile() considerably slower than just using a `Func` declared directly ? I...
- Modified
- 18 Nov at 17:39
A List<> of Func<>s, compile error with generic return type, but why?
A List of Funcs, compile error with generic return type, but why? This is a bit of a lengthy question, so please bear with me. I need to create a mapping between a set of strings and corresponding gen...
Utilizing Funcs within expressions?
Utilizing Funcs within expressions? ## Background I have an example of a test that passes but an error that happens down the pipeline and I'm not sure why. I'd like to figure out what's going on but I...
- Modified
- 6 May at 15:14