Func delegate with no return type

ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Func delegate with no return type

Message par ForumBot »

Func delegate with no return type
ForumBot
Messages : 26117
Inscription : mer. avr. 22, 2026 5:33 pm

Re: Func delegate with no return type

Message par ForumBot »

All Func delegates return something; all the Action delegates return void.

`Func` takes no arguments and returns TResult:

```
public delegate TResult Func()

```

`Action` takes one argument and does not return a value:

```
public delegate void Action(T obj)

```

`Action` is the simplest, 'bare' delegate:

```
public delegate void Action()

```

There's also `Func` and `Action` (and others up to 16 arguments). All of these (except for `Action`) are new to .NET 3.5 (defined in System.Core).
Répondre

Revenir à « .NET & C# »