Questions tagged [func]

Func is a family of delegate types in the .Net framework.

Func is a family of types in the framework. They are in the System namespace and can be used to represent a function that returns a value and has zero or more parameters.

1154 questions
-1
votes
1 answer

Lambda functions in generic C# method

I'm trying to better understand lambda expressions with generic methods, I have some code for opening a connection and getting some information from a session I frequently use. My goal is to pass in a object of Type T which can then get data from…
Tim Kalinowski
  • 306
  • 5
  • 18
-1
votes
1 answer

Getting results from each method within a delegate

I'm using a delegate to hold a few methods that test a value and return a true/false result. After learning that a call to a delegate will only return the result of the last method in the delegate, I'm unsure of how to proceed. I'd like to receive…
Trent
  • 571
  • 1
  • 7
  • 15
-1
votes
2 answers

Accessing the out parameter of a Function when it is invoked through a Func

Apologies I haven't done very well with the title of the question, hopefully it will be apparenent with some code I've created a class that stores poker hand information as follows public class BestHandSummary { public Func Test {…
user48408
  • 3,234
  • 11
  • 39
  • 59
-1
votes
3 answers

How can I call another class method into another class method in PHP

I'm trying to get the method using call_user_func in PHP but the fact is I can't get it in proper way. My data is stored into another class method and I would like to fetch that data into another class method. First of all I've create an object with…
Adnan Shawkat
  • 188
  • 1
  • 12
-1
votes
1 answer

Wrong result of print in FUNC

I have problem with this code, the code need to print this result: 56789 56789 But the result is: 99999 99999 why? class Program { static int m_k = 0; static Func[] P=new Func[5]; static void F(int n,Func[] T) …
user2110287
-1
votes
1 answer

Await method with Func Delegate as parameter: compilation error

Initial Statement I would like to call asynchronously an operation to which I pass a delegate as a parameter (details below). The compiler gives me an error. Could someone point me in the right direction? Async function: private async Task
Iulian
  • 11
  • 2
-1
votes
1 answer

Can Ninject use an anonymous delegate (func) as a ConstructorArgument?

I have a repository abstract class that encapsulates pretty much all of the CRUD functionality: public abstract class DataRepository : IRepository where T : class { public DataContext Context { get; private set; } public…
Mathieu Guindon
  • 69,817
  • 8
  • 107
  • 235
-1
votes
4 answers

Passing method as parameter to function

Is there a way of passing in a method to a function as a parameter and then calling it via list.Sort()? I've tried this: public static string BuildHumanSitemap(Func sortMethod, params string[] classNames) { //calling…
DGibbs
  • 14,316
  • 7
  • 44
  • 83
-2
votes
1 answer

SwiftUI: Where to Populate Arrays?

A naive question that I'll ask naively. If I have an array: var testArray = [Double](repeating: 0.0, count: 100) And want to populate it, in this instance with some dummy data: func populateTestArray() { ForEach((0 ..< testArray.count), id:…
Edward Hasted
  • 3,201
  • 8
  • 30
  • 48
-2
votes
3 answers

Is there a way to take a synchronous method that may or may not return a value and add it to a List>?

In the process of refactoring some legacy code at work and part of it is to convert an instance of List to List>. Elsewhere in the codebase, there are several instances of something along the lines of this: entity.Tasks.Add(() =>…
UW_Huskies_01
  • 71
  • 1
  • 10
-2
votes
2 answers

How Can I read a string from a txt file line by line and run it with a function?

I have a txt file named a.txt. In this file a has a string per line. I want to append these strings line by line to the keyword = {} dict and run my double_letter function for each line of string. How can I do it? my double_letter function: keyword…
user19485047
-2
votes
2 answers

defining a fuction using the for loop / Python

I need to define a function using the for loop. it's purpose is to check whether a letter included in secret_word is already included in the old_letters_guessed list. if it is, the function returns True. else, False. This is what I wrote thus…
Natilir
  • 35
  • 3
-2
votes
3 answers

C# - Wait for Task with return value

I want to have a code block, which should be executed with a maximum time limit. If the functions hangs, it should be aborted. From this question I adapted the following solution: public static void ExecuteWithTimeLimit(int timeLimit_milliseconds,…
Pixel_95
  • 954
  • 2
  • 9
  • 21
-2
votes
1 answer

What is a possible approach to write strategy pattern in a functional style in C#?

There are several approaches in another languages like What is the functional analogue of a Strategy pattern? Strategy pattern in F# But what about implementation in c#? Any ideas?
-2
votes
3 answers

javascript explain this code function call it self

please someone explain this to me function func(x, n) { if (n == 1) { return x; } else { return x * func(x, n - 1); } } console.log(func(2, 4)); // 16 how do answer is 16 I could not understand more than this when if is false it…
essencode
  • 3
  • 5