Skip to content

Commit d29807a

Browse files
authored
Add delegate to builtin types (#45169)
* Add `delegate` to builtin types Fixes #44868 Add the `delegate` keyword to the list of builtin types (it was already covered under the builtin reference types). General edit. Cleanup the description of `dynamic` to point out the differences between `dynamic` and `object`/ * format tables
1 parent 7aac7bd commit d29807a

File tree

1 file changed

+33
-24
lines changed

1 file changed

+33
-24
lines changed

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

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Built-in types"
33
description: "Learn C# built-in value and reference types"
4-
ms.date: 02/19/2025
4+
ms.date: 03/07/2025
55
helpviewer_keywords:
66
- "types [C#], built-in"
77
- "built-in C# types"
@@ -10,39 +10,48 @@ helpviewer_keywords:
1010

1111
The following table lists the C# built-in [value](value-types.md) types:
1212

13-
|C# type keyword|.NET type|
14-
|--------------|-------------------------|
15-
|[`bool`](bool.md)|<xref:System.Boolean?displayProperty=nameWithType>|
16-
|[`byte`](integral-numeric-types.md)|<xref:System.Byte?displayProperty=nameWithType>|
17-
|[`sbyte`](integral-numeric-types.md)|<xref:System.SByte?displayProperty=nameWithType>|
18-
|[`char`](char.md)|<xref:System.Char?displayProperty=nameWithType>|
19-
|[`decimal`](floating-point-numeric-types.md)|<xref:System.Decimal?displayProperty=nameWithType>|
20-
|[`double`](floating-point-numeric-types.md)|<xref:System.Double?displayProperty=nameWithType>|
21-
|[`float`](floating-point-numeric-types.md)|<xref:System.Single?displayProperty=nameWithType>|
22-
|[`int`](integral-numeric-types.md)|<xref:System.Int32?displayProperty=nameWithType>|
23-
|[`uint`](integral-numeric-types.md)|<xref:System.UInt32?displayProperty=nameWithType>|
24-
|[`nint`](integral-numeric-types.md)|<xref:System.IntPtr?displayProperty=nameWithType>|
25-
|[`nuint`](integral-numeric-types.md)|<xref:System.UIntPtr?displayProperty=nameWithType>|
26-
|[`long`](integral-numeric-types.md)|<xref:System.Int64?displayProperty=nameWithType>|
27-
|[`ulong`](integral-numeric-types.md)|<xref:System.UInt64?displayProperty=nameWithType>|
28-
|[`short`](integral-numeric-types.md)|<xref:System.Int16?displayProperty=nameWithType>|
29-
|[`ushort`](integral-numeric-types.md)|<xref:System.UInt16?displayProperty=nameWithType>|
13+
| C# type keyword | .NET type |
14+
|----------------------------------------------|----------------------------------------------------|
15+
| [`bool`](bool.md) | <xref:System.Boolean?displayProperty=nameWithType> |
16+
| [`byte`](integral-numeric-types.md) | <xref:System.Byte?displayProperty=nameWithType> |
17+
| [`sbyte`](integral-numeric-types.md) | <xref:System.SByte?displayProperty=nameWithType> |
18+
| [`char`](char.md) | <xref:System.Char?displayProperty=nameWithType> |
19+
| [`decimal`](floating-point-numeric-types.md) | <xref:System.Decimal?displayProperty=nameWithType> |
20+
| [`double`](floating-point-numeric-types.md) | <xref:System.Double?displayProperty=nameWithType> |
21+
| [`float`](floating-point-numeric-types.md) | <xref:System.Single?displayProperty=nameWithType> |
22+
| [`int`](integral-numeric-types.md) | <xref:System.Int32?displayProperty=nameWithType> |
23+
| [`uint`](integral-numeric-types.md) | <xref:System.UInt32?displayProperty=nameWithType> |
24+
| [`nint`](integral-numeric-types.md) | <xref:System.IntPtr?displayProperty=nameWithType> |
25+
| [`nuint`](integral-numeric-types.md) | <xref:System.UIntPtr?displayProperty=nameWithType> |
26+
| [`long`](integral-numeric-types.md) | <xref:System.Int64?displayProperty=nameWithType> |
27+
| [`ulong`](integral-numeric-types.md) | <xref:System.UInt64?displayProperty=nameWithType> |
28+
| [`short`](integral-numeric-types.md) | <xref:System.Int16?displayProperty=nameWithType> |
29+
| [`ushort`](integral-numeric-types.md) | <xref:System.UInt16?displayProperty=nameWithType> |
3030

3131
The following table lists the C# built-in [reference](../keywords/reference-types.md) types:
3232

33-
|C# type keyword|.NET type|
34-
|--------------|-------------------------|
35-
|[`object`](reference-types.md#the-object-type)|<xref:System.Object?displayProperty=nameWithType>|
36-
|[`string`](reference-types.md#the-string-type)|<xref:System.String?displayProperty=nameWithType>|
37-
|[`dynamic`](reference-types.md#the-dynamic-type)|<xref:System.Object?displayProperty=nameWithType>|
33+
| C# type keyword | .NET type |
34+
|----------------------------------------------------|----------------------------------------------------|
35+
| [`object`](reference-types.md#the-object-type) |<xref:System.Object?displayProperty=nameWithType> |
36+
| [`string`](reference-types.md#the-string-type) |<xref:System.String?displayProperty=nameWithType> |
37+
| [`delegate`](reference-types.md#the-delegate-type) |<xref:System.Delegate?displayProperty=nameWithType> |
38+
| [`dynamic`](reference-types.md#the-dynamic-type) |<xref:System.Object?displayProperty=nameWithType> |
3839

39-
In the preceding tables, each C# type keyword from the left column (except [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, 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:
4041

4142
```csharp
4243
int a = 123;
4344
System.Int32 b = 123;
4445
```
4546

47+
The `dynamic` type is similar to `object`. The main differences are:
48+
49+
- Operations on a `dynamic` expression are bound at runtime, not at compile time.
50+
- You can't use `new dynamic()`.
51+
- You can't derive a type from the `dynamic` type.
52+
53+
The `delegate` keyword declares a type derived from <xref:System.Delegate?displayProperty=nameWithType>. `System.Delegate` type is an abstract type.
54+
4655
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.
4756

4857
The C# language includes specialized rules for the <xref:System.Span`1?displayProperty=fullName> and <xref:System.ReadOnlySpan`1?displayProperty=fullName> types. These types aren't classified as built-in types, because there aren't C# keywords that correspond to these types. The C# language defines implicit conversions from array types and the string type to `Span<T>` and `ReadOnlySpan<T>`. These conversions integrate `Span` types into more natural programming scenarios. The following conversions are defined as *implicit span conversions*:

0 commit comments

Comments
 (0)