func Questions

2

Just as the title says: What, if any, are the security implications that need to be considered when using and/or passing around anonymous methods (Action<>, Func<>) in C#? A method whi...
Cadaverine asked 4/1, 2015 at 17:19

2

Solved

I read that C# lambdas can be imlicitly converted to Action or Func , but lambda cannot be executed directly Define a lambda function and execute it immediately For example : int n = (()=>5)()...
Faustena asked 6/1, 2015 at 9:38

1

Solved

I want to create within a function a named lambda function, so that I can call it repeatedly afterwards in the same function. I used to do this synchronously/without tasks with Func<string, bo...
Muscat asked 5/1, 2015 at 20:22

8

Solved

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: public static MvcHtmlString PageLinks(this HtmlHelper html...
Suit asked 15/3, 2011 at 17:23

3

Solved

I have this method public static T F<T>(T arg) { return arg; } and I want to create a Func delegate to F. I try this public Func<T, T> FuncF = F; but it's not syntactically co...
Menadione asked 5/11, 2014 at 13:53

1

Okay, let me set the scene: We have a function used within our code that takes a function and does some logging around it and then returns the result. It looks a little something like this. TRespo...
Omaromara asked 21/10, 2014 at 9:42

2

Solved

I have a Func<ProductItemVendor, bool> stored in CompareProductItemVendorIds. I would like to use that expression in a LINQ query. It appears the following is legal: var results = Reposito...
Scuttlebutt asked 28/10, 2014 at 20:13

2

Solved

I have a function of this sort void func(params object[] parameters) { //Function Body } It can accept parameters of the following sort func(10, "hello", 30.0); func(10,20); and so on. I w...
Northwest asked 5/9, 2014 at 16:33

2

Solved

In Java (1.7), is it possible to define multiple interfaces with the same name, but with a different number of type parameters? What I'm essentially looking for is in spirit similar to the Func<...
Lulualaba asked 2/8, 2014 at 9:19

1

Solved

Is there any difference between the following two statement? They both work. if ( ((Func<bool>)(()=>true))() ) { .... }; if ( new Func<bool>(()=>true)()) { .... };
Warhead asked 11/7, 2014 at 20:23

2

Solved

this should be a asked-before question, I searched but I could not find any answer on that. Sorry if it is duplicated. I have a query lets say: my_query=session.query(Item).filter(somefilter) No...
Sonorant asked 16/1, 2013 at 3:53

2

Solved

I have some fairly complex Entity Framework queries throughout my codebase and I decided to centralize the logic into the models. Basically, picture a bunch of controllers with large queries and lo...
Submediant asked 19/6, 2014 at 21:10

1

I wish to check if a func exists before I call it. For example: if let touch: AnyObject = touches.anyObject() { let location = touch.locationInView(self) touchMoved(Int(location.x), Int(locatio...
Photochromy asked 11/6, 2014 at 23:51

2

Solved

public object MethodName(ref float y) { // elided } How do I define a Func delegate for this method?
Sfumato asked 17/3, 2010 at 14:4

3

I have a parametric method that takes a Func as an argument SomeType SomeMethod<T>( Func<T, T> f ) {...} I would like to pass an Action without having to overload the method. But thi...
Astraea asked 30/5, 2014 at 17:40

5

As mentioned in this question, methods expecting a Func will not accept an F# function value. What's a good approach to overloading a method such that it will accept F# function values?
Balsam asked 23/4, 2014 at 6:5

1

Solved

Given the following: open System.Linq let seqA = { 1..10 } this works: seqA.All (fun n -> n > 0) However this doesn't: let abc = fun n -> n > 0 seqA.All (abc) Why does F# off...
Totally asked 23/4, 2014 at 3:7

2

Solved

I have method in c# with some parameters: public static void DeleteSingleItemInDataGrid (DataGrid dataGrid, String IDcolumnName, Func<int> afterCompletionMethod_ToRun) I want to change th...
Kepi asked 22/4, 2014 at 9:51

9

Solved

Going from a lambda to an Expression is easy using a method call... public void GimmeExpression(Expression<Func<T>> expression) { ((MemberExpression)expression.Body).Member.Name; // "...
Romanticist asked 20/4, 2009 at 10:40

3

Solved

Why does the following compile? It sure seems like the compiler has enough info to know that the attempted assignment is invalid, since the return type of the Func<> is not dynamic. Func<dyn...
Vestavestal asked 24/1, 2014 at 18:43

1

Solved

I have a class like this: class MyClass { public object[] Values; } Somewhere else I'm using it: MyClass myInstance = new MyClass() {Values = new object[]{"S", 5, true}}; List<Func<MyCla...
Incurve asked 23/12, 2013 at 8:6

3

Solved

In an effort to learn more about Func Delegates and Expression trees, I put together a simple example, however I am not getting the results I expect. Below is my code that has a Func that expects a...
Pulpiteer asked 21/12, 2013 at 15:30

4

Solved

Can I pass a method with an out parameter as a Func? public IList<Foo> FindForBar(string bar, out int count) { } // somewhere else public IList<T> Find(Func<string, int, List<T&...
Dissimilate asked 15/8, 2009 at 23:45

5

Solved

So when I return an object, under the covers I think it's returning the memory address to that object (or an object containing the memory address) which you can reference and use. But what is act...
Wilberwilberforce asked 12/12, 2013 at 20:13

3

Solved

I have static method like this : public static string MyMethod(Func<Student, object> func) { return ??? ; } and I use it as following : var s1 = MyMethod(student => student...
Jennet asked 12/12, 2013 at 20:5

© 2022 - 2024 — McMap. All rights reserved.