func Questions
4
Solved
I was wondering if someone could explain what Func<int, string> is and how it is used with some clear examples.
3
Solved
I have a question wheater or not it is possible (and if it is, how) to access class members from inside a Func<T, TResult> delegate.
For example, I have the following class:
class NinjaTurt...
5
Solved
I have...
Func<string> del2 = new Func<string>(MyMethod);
and I really want to do..
Func<> del2 = new Func<>(MyMethod);
so the return type of the callback method is vo...
1
Solved
I've been looking into Functional Programming lately and wanting to bring some concepts to my C# world. I'm trying to compose functions to create services (or whatever you'd call them) instead of c...
Singleton asked 1/6, 2018 at 8:41
5
So I'm attempting to be able to pass a Func with a variable number of parameters.
Something like:
public object GetValue<T>(string name, Func<object> func) {
var result = func.Dynam...
1
Is there any way to convert an existing Func delegate to a string like that:
Func<int, int> func = (i) => i*2;
string str = someMethod(func); // returns "Func<int, int> func = (i) =...
2
Solved
I'm curious about the differences between calling a Func<T> directly vs. using Invoke() on it. Is there a difference? Is the first syntactical sugar and calls Invoke() underneath anyway?
publ...
2
I am working on an automation for instantiating classes dynamically.
I decided to write an expression tree that would generate a Func, that could instantiate my class for me. However, I am noticin...
Constanceconstancia asked 4/1, 2018 at 16:30
2
Solved
I provided following query (simplified version) to return an IQueryable from my service:
var query =
(from item in _entityRepository.DbSet()
where
MyCondition
orderby Entity.EntityID descendin...
Partible asked 10/12, 2017 at 23:40
1
Solved
2
Solved
I am trying to run a function in certain ViewController using AppDelegate
func applicationDidBecomeActive(_ application: UIApplication) {
ViewController().grabData()
}
But somehow the function ...
Lascar asked 7/5, 2017 at 12:41
4
Solved
How can I map
from: Expression<Func<TEntity, bool>>
to: Expression<Func<TDbEntity, bool>>
where TEntity: class, new() and TDbEntity: class, new()
TEntity is from Domain...
Allomorph asked 20/3, 2017 at 11:15
2
Solved
I'm trying to pass a Predicate to a function but it has no input. I'm actually trying to delay the computation until the call is made.
Is there a way to use c# Predicate type for that? If not why....
Achieve asked 14/3, 2017 at 9:26
5
I know how to use Action and Func in .NET, but every single time I start to, the exact same solution can be achieved with a regular old Method that I call instead.
This excludes when an Action or...
8
Solved
Today I was thinking about declaring this:
private delegate double ChangeListAction(string param1, int number);
but why not use this:
private Func<string, int, double> ChangeListAction;
...
4
Solved
I am looking for an elegant solution to aggregate a child collection in a collection into one large collection. My issue is when certain child collections could be null.
EG:
var aggregatedChild...
Missionary asked 5/9, 2016 at 23:55
2
Solved
I want to pass the selector for a function to another function. Right now I'm just passing the string and doing several if statements. If I could pass the actual function selector to the function, ...
4
Solved
Update
In C#10, this syntax is now valid and the compiler will infer a 'natural type' for a lambda Example here
C# 9 and Earlier
I am aware that Func<>s cannot be implicitly typed direc...
2
Solved
I have the following expression:
public Expression<Func<T, bool>> UserAccessCheckExpression<T>(int userId) where T : class
{
return x => (IsAdmin || userId == CurrentUserId |...
Programme asked 20/4, 2016 at 7:3
4
Solved
Tried to something like this in our code but it fails:
Func<Employee, Employee> _myFunc;
void Main()
{
Func<Employee, Employee> test1 = _myFunc;//Ok
Func<Employee, Person> tes...
Concede asked 15/3, 2016 at 9:18
1
Solved
I use following code to parse html template. It works well.
func test(w http.ResponseWriter, req *http.Request) {
data := struct {A int B int }{A: 2, B: 3}
t := template.New("test.html").Funcs...
Kinsey asked 3/12, 2015 at 5:50
1
Solved
I have a variable of type Func<dynamic> and I am trying to assign it a value. If I assign it to a method that returns a value type (e.g. int), I get the error
'int MethodName()' has ...
2
Solved
I have an interface that defines a repository from the Repository pattern:
interface IRepository
{
List<Customer> GetAllCustomers(Expression<Func<Customer, bool>> expression);
}...
Carmacarmack asked 24/9, 2015 at 3:51
3
Solved
I was tampering with Expressions and I got confused at some points
We can assign same LamdaExpression to both Expression and/or Func. But we cannot assign a Func to an Expression (or an Expressio...
Athome asked 5/1, 2013 at 19:29
1
Solved
I'd like to write a method which does some work and finally returns another method with the same signature as the original method. The idea is to handle a stream of bytes depending on the previous ...
© 2022 - 2024 — McMap. All rights reserved.