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

Create an Array of square numbers with a variadic integer as an input in Swift

I’m new to this and maybe this is a very bad approach, so let me know please. I want to create an array of integers by a function that use variadic integers as an input and return the square of those integers in an array. But at the end I forced to…
Bezi
  • 57
  • 1
  • 7
-1
votes
1 answer

What the function's signature means?

#ifndef _RECT #define _RECT #include "Point.h" using namespace std; class Rectangle { private: Point _topLeft; Point _bottomRight; int _color; public: Rectangle( double left, double top, double width, double height, int color…
Sherry Bar
  • 11
  • 2
-1
votes
3 answers

React: Calling functions, why the first one works and not the second one?

Maybe this is a silly question but I want to know why is it so that... const isDisabled = () => // condition check This works: but this does not work:
-1
votes
1 answer

How can I write a single method instead of two methods that has a single Boolean expression differences

Let's say I have two methods. One checks registry key with exact match and one checks vague registry key check. public bool exactCheck(string name) { // something common for(...) { string displayName = ... subkey get common code ... if…
Shintaro Takechi
  • 1,215
  • 1
  • 17
  • 39
-1
votes
1 answer

Why javascript is triggering multiple functions

I want to take the count of button clicks along with the count of clicks OUT OF THE BUTTON ON PAGE anywhere. In order to achieve that I generated two functions. One inside button element and the other one inside the HTML element. My problem is…
firehorse
  • 25
  • 5
-1
votes
2 answers

Is it possible to extract code into delegate?

Update: The issue I had is model validation, but I found FluentValidation already taking care of this when the model passed to Action, so my question is not completely correct and probably misleading. I will close it (if find how to do it). I have…
Yaplex
  • 2,272
  • 1
  • 20
  • 38
-1
votes
3 answers

C# How to pass a variable into a func?

Simple version var myVar = some object; myList.Where(element => myVar != null && element.Name == myVar.Name) What I want to write public static (Return Value) Start(this T input, Func<(IDK what goes here)> exp) { var theVar = somehow get the…
-1
votes
1 answer

Issue with code that takes in 2 positive numbers and prints every prime number in between? - Swift

I am trying to write a function that takes in 2 positive integers and prints every prime number in between them, and also including the 2 numbers as well if they are prime. This is what I have currently, but it will just print the first number is…
Ash
  • 47
  • 8
-1
votes
4 answers

Execute function after another function is triggered when selecting an item from a tableView

When an item is selected within my tableView, I want the first func, fetchChosenExerciseData, to be executed before the second, goToSegue, is triggered. How can I implement this? I have had a look at completion blocks but to no avail. A snippet of…
gcpreston
  • 135
  • 1
  • 12
-1
votes
1 answer

Cast Expression> to Expression>

I have an Expression> object and I need to cast it to the Expression> object. In fact I have this: x => new <>f__AnonymousType6`1(MyProp = x.MyProp) and I need to have it as: x => new MyType(){MyProp =…
Vahid Farahmandian
  • 6,081
  • 7
  • 42
  • 62
-1
votes
2 answers

Struct as parameter in function with Completion - Swift

I'm in trouble, there is the possibility to set a parameter of function inside the Completion? In specific I have 2 structs and I want that the user will select one of them. My code is something like this: struct Photo: Decodable…
Pietro Messineo
  • 777
  • 8
  • 28
-1
votes
1 answer

Explain the printed values of method expressions

The following code tries to show the address of a method associated to struct. package main import ( "fmt" "reflect" ) type II interface { Callme() } type Str struct { I int S string } func (s *Str) Callme () { …
river
  • 694
  • 6
  • 22
-1
votes
2 answers

Best pratices for Func and Func

Let us suppose that I have two functions like: public T Foo(Func func){ return func(); } public TResult Foo(Func func, T param){ return func(param); } And I have the following code to…
Andre
  • 652
  • 2
  • 7
  • 23
-1
votes
1 answer

c# - keep trying to connect to Server through Func - but SqlConnection parameter stays null

I am trying to write a method that "tries again" when some Database (SQL-Server) related stuff fails the first time. After the job is done (or failed), the given connection should be closed. But in the finally block the connection-object stays…
Jan
  • 333
  • 2
  • 15
-1
votes
1 answer

Invoke Func with unknown return type

I'm trying to invoke the Func below, but I'd like the ??? part of it to be filled in at the moment of invoking. public void Publish(string topic) { ... // 'actions' is a List of delegates, defined as List