Skip to content

Commit 2d21c75

Browse files
shethaaditAdit Sheth
andauthored
Fixed bug 44001. (#44018)
Co-authored-by: Adit Sheth <[email protected]>
1 parent e78758d commit 2d21c75

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

docs/csharp/whats-new/csharp-13.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,11 @@ You can read the details of the changes in the [proposal specification](~/_cshar
7676
The implicit "from the end" index operator, `^`, is now allowed in an object initializer expression. For example, you can now initialize an array in an object initializer as shown in the following code:
7777

7878
```csharp
79+
public class TimerRemaining
80+
{
81+
public int[] buffer { get; set; } = new int[10];
82+
}
83+
7984
var countdown = new TimerRemaining()
8085
{
8186
buffer =
@@ -94,7 +99,9 @@ var countdown = new TimerRemaining()
9499
};
95100
```
96101

97-
The preceding example creates an array that counts down from 9 to 0. In versions before C# 13, the `^` operator can't be used in an object initializer. You need to index the elements from the front.
102+
The `TimerRemaining` class includes a `buffer` array initialized to a length of 10. The preceding example assigns values to this array using the "from the end" index operator (`^`), effectively creating an array that counts down from 9 to 0.
103+
104+
In versions before C# 13, the `^` operator can't be used in an object initializer. You need to index the elements from the front.
98105

99106
## `ref` and `unsafe` in iterators and `async` methods
100107

0 commit comments

Comments
 (0)