We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code doesn't work
The implicit index access example seemed not working
int[] numbers = { [^1] = 4, [^2] = 3, [^3] = 2, [^4] = 1, };
CS0131: The left-hand side of an assignment must be a variable, property or indexer
And I'm using the latest vs preview and targeted net9.0 with .NET 9 RC1 SDK installed
net9.0
https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-13#implicit-index-access
https://github.com/dotnet/docs/blob/main/docs/csharp/whats-new/csharp-13.md
587ed47f-f532-e018-9b0d-6ee76afd20e4
@BillWagner
The text was updated successfully, but these errors were encountered:
The array needs to be inside of an object, there's an example
internal class ImplicitIndexAccessSample { public static void Main() { var a = new TestClass() { Numbers = { [0] = 3, [^1] = 1 } }; foreach (var item in a.Numbers) { Console.WriteLine(item); } // output 3 0 1 } } file sealed class TestClass { public int[] Numbers { get; init; } = new int[3]; }
Sorry, something went wrong.
No branches or pull requests
Type of issue
Code doesn't work
Description
The implicit index access example seemed not working
And I'm using the latest vs preview and targeted
net9.0
with .NET 9 RC1 SDK installedPage URL
https://learn.microsoft.com/en-us/dotnet/csharp/whats-new/csharp-13#implicit-index-access
Content source URL
https://github.com/dotnet/docs/blob/main/docs/csharp/whats-new/csharp-13.md
Document Version Independent Id
587ed47f-f532-e018-9b0d-6ee76afd20e4
Article author
@BillWagner
Metadata
The text was updated successfully, but these errors were encountered: