Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/csharp/language-reference/operators/default.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,19 @@ f1_keywords:
helpviewer_keywords:
- "default keyword [C#]"
---
# default value expressions - produce the default value
# Default value expressions - produce the default value

A default value expression produces the [default value](../builtin-types/default-values.md) of a type. There are two kinds of default value expressions: the [default operator](#default-operator) call and a [default literal](#default-literal).
A default value expression produces the [default value](../builtin-types/default-values.md) of a type. There are two kinds of default value expressions: the [`default` operator](#default-operator) call and a [`default` literal](#default-literal).

You also use the `default` keyword as the default case label within a [`switch` statement](../statements/selection-statements.md#the-switch-statement).

## default operator
## `default` operator

The argument to the `default` operator must be the name of a type or a type parameter, as the following example shows:

[!code-csharp[default of T](snippets/shared/DefaultOperator.cs#WithOperand)]

## default literal
## `default` literal

You can use the `default` literal to produce the default value of a type when the compiler can infer the expression type. The `default` literal expression produces the same value as the `default(T)` expression where `T` is the inferred type. You can use the `default` literal in any of the following cases:

Expand Down
12 changes: 6 additions & 6 deletions docs/csharp/language-reference/toc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ items:
items:
- name: "null"
href: ./keywords/null.md
- name: "true and false"
- name: true and false
href: ./builtin-types/bool.md
- name: default
href: ./keywords/default.md
Expand Down Expand Up @@ -220,7 +220,7 @@ items:
href: ./keywords/ascending.md
- name: descending
href: ./keywords/descending.md
- name: "on"
- name: on
href: ./keywords/on.md
- name: equals
href: ./keywords/equals.md
Expand Down Expand Up @@ -272,7 +272,7 @@ items:
- name: Patterns
href: ./operators/patterns.md
displayName: pattern matching, and keyword, or keyword, not keyword, pattern reference
- name: + and += operators
- name: "+ and += operators"
href: ./operators/addition-operator.md
displayName: string concatenation, delegate combination, event subscription
- name: "- and -= operators"
Expand All @@ -296,7 +296,7 @@ items:
- name: await operator
href: ./operators/await.md
displayName: async
- name: default value expressions
- name: Default value expressions
href: ./operators/default.md
displayName: default value, default operator, default literal, type default
- name: delegate operator
Expand Down Expand Up @@ -524,7 +524,7 @@ items:
CS0080, CS0081, CS0224, CS0304, CS0305, CS0306, CS0307, CS0308, CS0310, CS0311,
CS0312, CS0313, CS0314, CS0315, CS0403, CS0412, CS0413, CS0417, CS0694, CS0695,
CS0698, CS9338
- name: asynchronous methods
- name: Asynchronous methods
href: ./compiler-messages/async-await-errors.md
displayName: >
async, await,
Expand Down Expand Up @@ -554,7 +554,7 @@ items:
CS8166, CS8167, CS8168, CS8169, CS8345, CS8351, CS8374, CS9075, CS9076, CS9077,
CS9078, CS9079, CS9080, CS9081, CS9082, CS9083, CS9084, CS9085, CS9086, CS9087,
CS9088, CS9089, CS9090, CS9091, CS9092, CS9093, CS9094, CS9095, CS9096, CS9097
- name: "`ref struct` types"
- name: ref struct types
href: ./compiler-messages/ref-struct-errors.md
displayName: >
ref struct,
Expand Down