Skip to content

[C# 14-Fundamentals and reference]: New Feature - User defined compound assignment operators #46100

Closed
@BillWagner

Description

@BillWagner

Visual Studio release

other - specify below

Link to speclet

Link to Pull request

New behavior

Type authors can now define the behavior for compound assignment operators, such as += or *=.

Prior to this, authors could override +, and *, bur not =. The compound assignment operators have been defined to call the binary arithmetic operators and then the assignment operator.

This will allow authors to provide a "modify in place" implementation.

Language reference tasks

  • This removes a restriction on these operators.
  • It expands the list of overridable operators.
  • Check all docs for where the (now invalid) restriction has been mentioned.

Everyday C# tasks

No response


Associated WorkItem - 431829

Metadata

Metadata

Assignees

Type

No type

Projects

Status

✅ Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions