The ^
operator introduced with Ranges C# 8.0 could not be used in object initializers. C# 13.0 allows the ^
operator to be used in object initializers.
Code
C#
var greeter = new Greeter { Message = { [^1] = '!' }};
class Greeter
{
public char[] Message { get; set; } = "Hello?".ToCharArray();
}
C#
var greeter = new Greeter();
greeter.Message[^1] = '!';
class Greeter
{
public char[] Message { get; set; } = "Hello?".ToCharArray();
}