Skip to content

Commit 7c83e3f

Browse files
CopilotBillWagnergewarren
authored
Clarify delegate as built-in reference type in documentation (dotnet#47668)
* Initial plan * Initial analysis: Understanding delegate type classification issue Co-authored-by: BillWagner <[email protected]> * Clarify delegate as built-in type in documentation Co-authored-by: BillWagner <[email protected]> * Remove package.json files from tracking * Remove unrelated .gitignore change for node_modules Co-authored-by: gewarren <[email protected]> --------- Co-authored-by: copilot-swe-agent[bot] <[email protected]> Co-authored-by: BillWagner <[email protected]> Co-authored-by: gewarren <[email protected]>
1 parent 1cef022 commit 7c83e3f

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

docs/csharp/language-reference/builtin-types/built-in-types.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ The following table lists the C# built-in [reference](../keywords/reference-type
3737
| [`delegate`](reference-types.md#the-delegate-type) |<xref:System.Delegate?displayProperty=nameWithType> |
3838
| [`dynamic`](reference-types.md#the-dynamic-type) |<xref:System.Object?displayProperty=nameWithType> |
3939

40-
In the preceding tables, the C# type keyword from the left column (except [delegate](reference-types.md#the-delegate-type) and [dynamic](reference-types.md#the-dynamic-type)) is an alias for the corresponding .NET type. They're interchangeable. For example, the following declarations declare variables of the same type:
40+
In the preceding tables, most C# type keywords from the left column are aliases for the corresponding .NET type. They're interchangeable. For example, the following declarations declare variables of the same type:
4141

4242
```csharp
4343
int a = 123;
@@ -50,7 +50,7 @@ The `dynamic` type is similar to `object`. The main differences are:
5050
- You can't use `new dynamic()`.
5151
- You can't derive a type from the `dynamic` type.
5252

53-
The `delegate` keyword declares a type derived from <xref:System.Delegate?displayProperty=nameWithType>. `System.Delegate` type is an abstract type.
53+
The `delegate` keyword is a built-in reference type keyword that declares a type derived from <xref:System.Delegate?displayProperty=nameWithType>. Unlike the other built-in type keywords, `delegate` isn't an alias for a specific .NET type. Instead, it declares custom types that derive from the abstract `System.Delegate` type. Similarly, `dynamic` represents runtime binding behavior rather than being a direct alias for a specific .NET type.
5454

5555
The [`void`](void.md) keyword represents the absence of a type. You use it as the return type of a method that doesn't return a value.
5656

docs/csharp/language-reference/builtin-types/reference-types.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ public delegate int AnotherDelegate(MyType m, long num);
210210

211211
In .NET, `System.Action` and `System.Func` types provide generic definitions for many common delegates. You likely don't need to define new custom delegate types. Instead, you can create instantiations of the provided generic types.
212212

213-
A `delegate` is a reference type that can be used to encapsulate a named or an anonymous method. Delegates are similar to function pointers in C++; however, delegates are type-safe and secure. For applications of delegates, see [Delegates](../../programming-guide/delegates/index.md) and [Generic Delegates](../../programming-guide/generics/generic-delegates.md). Delegates are the basis for [Events](../../programming-guide/events/index.md). A delegate can be instantiated by associating it either with a named or anonymous method.
213+
A `delegate` is a built-in reference type that can be used to encapsulate a named or an anonymous method. Delegates are similar to function pointers in C++; however, delegates are type-safe and secure. For applications of delegates, see [Delegates](../../programming-guide/delegates/index.md) and [Generic Delegates](../../programming-guide/generics/generic-delegates.md). Delegates are the basis for [Events](../../programming-guide/events/index.md). A delegate can be instantiated by associating it either with a named or anonymous method.
214214

215215
The delegate must be instantiated with a method or lambda expression that has a compatible return type and input parameters. For more information on the degree of variance that is allowed in the method signature, see [Variance in Delegates](../../programming-guide/concepts/covariance-contravariance/using-variance-in-delegates.md). For use with anonymous methods, the delegate and the code to be associated with it are declared together.
216216

0 commit comments

Comments
 (0)