-
When I try to use the implicit indexer access example for the document, could not make it work, did I miss something? int[] numbers =
{
[^1] = 4,
[^2] = 3,
[^3] = 2,
[^4] = 1,
}; Would get an error likes related docs issue: dotnet/docs#42674 |
Beta Was this translation helpful? Give feedback.
Answered by
WeihanLi
Sep 21, 2024
Replies: 1 comment
-
need to be inside a object internal class ImplicitIndexAccessSample
{
public static void MainTest()
{
var a = new TestClass()
{
Numbers =
{
[0] = 3,
[^1] = 1
}
};
foreach (var item in a.Numbers)
{
Console.WriteLine(item);
}
}
}
file sealed class TestClass
{
public int[] Numbers { get; init; } = new int[3];
} |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
WeihanLi
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
need to be inside a object