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...
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)()...
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...
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...
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...
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...
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...
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<...
1
Solved
Is there any difference between the following two statement? They both work.
if ( ((Func<bool>)(()=>true))() ) { .... };
if ( new Func<bool>(()=>true)()) { .... };
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...
2
Solved
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...
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...
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...
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...
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...
4
Solved
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...
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...
© 2022 - 2024 — McMap. All rights reserved.