You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Anonymous types support *projection initializers*, which allow you to use local variables or parameters directly without explicitly specifying the member name. The compiler infers the member names from the variable names. The following example demonstrates this simplified syntax:
The member name isn't inferred in the following cases:
52
+
53
+
- The candidate name is a member name of an anonymous type, such as `ToString` or `GetHashCode`.
54
+
- The candidate name is a duplicate of another property member in the same anonymous type, either explicit or implicit.
55
+
- The candidate name isn't a valid identifier (for example, it contains spaces or special characters).
56
+
57
+
In these cases, you must explicitly specify the member name.
58
+
41
59
> [!TIP]
42
60
> You can use .NET style rule [IDE0037](../../../fundamentals/code-analysis/style-rules/ide0037.md) to enforce whether inferred or explicit member names are preferred.
0 commit comments