Skip to content
Merged
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 .openpublishing.redirection.csharp.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
{
"redirections": [
{
"source_path_from_root": "/docs/csharp/fundamentals/types/anonymous-types.md",
"redirect_url": "/dotnet/csharp/fundamentals/types/tuples"
},
{
"source_path_from_root": "/docs/csharp/fundamentals/types/namespaces.md",
"redirect_url": "/dotnet/csharp/fundamentals/program-structure/namespaces"
Expand Down Expand Up @@ -3065,10 +3069,6 @@
"source_path_from_root": "/docs/csharp/programming-guide/arrays/passing-arrays-using-ref-and-out.md",
"redirect_url": "/dotnet/csharp/programming-guide/arrays"
},
{
"source_path_from_root": "/docs/csharp/programming-guide/classes-and-structs/anonymous-types.md",
"redirect_url": "/dotnet/csharp/fundamentals/types/anonymous-types"
},
{
"source_path_from_root": "/docs/csharp/programming-guide/classes-and-structs/classes.md",
"redirect_url": "/dotnet/csharp/fundamentals/types/classes"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ A typical call site will look like:
:::code language="csharp" source="snippets/diagnosticsource/csharp/Program.cs" id="Snippet3":::

Every event has a `string` name (for example, `RequestStart`), and exactly one `object` as a payload.
If you need to send more than one item, you can do so by creating an `object` with properties to represent all its information. C#'s [anonymous type](../../csharp/fundamentals/types/anonymous-types.md)
If you need to send more than one item, you can do so by creating an `object` with properties to represent all its information. C#'s [anonymous type](../../csharp/programming-guide/classes-and-structs/anonymous-types.md)
feature is typically used to create a type to pass 'on the fly', and makes this scheme very
convenient. At the instrumentation site, you must guard the call to `Write()` with an `IsEnabled()` check on
the same event name. Without this check, even when the instrumentation is inactive, the rules
Expand Down
2 changes: 1 addition & 1 deletion docs/csharp/fundamentals/object-oriented/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ You can instantiate and initialize class or struct objects, and collections of o

## Anonymous Types

In situations where it isn't convenient or necessary to create a named class you use anonymous types. Named data members define anonymous types. For more information, see [Anonymous types](../types/anonymous-types.md).
In situations where it isn't convenient or necessary to create a named class, you can use anonymous types or [tuples](../types/tuples.md). Named data members define anonymous types. Tuples are the preferred choice for new code because they offer better performance and deconstruction support. For more information, see [Tuples and deconstruction](../types/tuples.md).

## Extension Members

Expand Down
141 changes: 0 additions & 141 deletions docs/csharp/fundamentals/types/anonymous-types.md

This file was deleted.

8 changes: 4 additions & 4 deletions docs/csharp/fundamentals/types/enums.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "C# Enumerations"
description: Learn how to define and use enumeration types in C#, including declaring enums, using them in switch expressions, working with bit flags, and converting between enums and integers.
ms.date: 03/24/2026
ms.date: 04/10/2026
ms.topic: concept-article
ai-usage: ai-assisted
---
Expand All @@ -12,7 +12,7 @@ ai-usage: ai-assisted
>
> **Experienced in another language?** C# enums work similarly to enums in Java or C++, with additional support for bit flags and pattern matching. Skim the [flags](#bit-flags) and [switch expression](#use-enums-in-switch-expressions) sections for C#-specific patterns.

An *enumeration type* (or *enum*) defines a set of named constants backed by an integer value. Use enums when a value must be one of a fixed set of optionsdays of the week, HTTP status codes, log levels, or directions. Enums make your code more readable and less error-prone than raw integer constants because the compiler enforces the named values.
An *enumeration type* (or *enum*) defines a set of named constants backed by an integer value. Use enums when a value must be one of a fixed set of options, such as days of the week, HTTP status codes, log levels, or directions. Enums make your code more readable and less error-prone than raw integer constants because the compiler enforces the named values.

## Declare an enum

Expand All @@ -38,7 +38,7 @@ Enums work naturally with `switch` expressions and pattern matching. The compile

:::code language="csharp" source="snippets/enums/Program.cs" ID="UsingSeason":::

The discard pattern (`_`) handles any value not explicitly listed. *Pattern matching* is a C# feature that tests a value against a shape or condition. In this example, each `case` checks whether the enum matches a specific member. Switch expressions are one of several pattern matching forms. For more information about pattern matching, see [Pattern matching](../functional/pattern-matching.md).
The discard pattern (`_`) handles any value not explicitly listed. Because an enum's underlying type is an integer, a variable can hold a value that doesn't correspond to any named member. For example, `(Season)99` is valid at runtime. The discard pattern ensures the switch expression handles those unexpected values safely. *Pattern matching* is a C# feature that tests a value against a shape or condition. In this example, each `case` checks whether the enum matches a specific member. Switch expressions are one of several pattern matching forms. For more information about pattern matching, see [Pattern matching](../functional/pattern-matching.md).

## Bit flags

Expand All @@ -54,7 +54,7 @@ The `[Flags]` attribute also affects `ToString()`. It displays combined values a

## Convert between enums and integers

Explicit casts convert between an enum and its underlying integer type:
Explicit [cast expressions](../../language-reference/operators/type-testing-and-cast.md#cast-expression) convert between an enum and its underlying integer type. An explicit cast uses the `(Type)value` syntax to tell the compiler you intend the conversion:

:::code language="csharp" source="snippets/enums/Program.cs" ID="Conversions":::

Expand Down
Loading
Loading