链接见
https://learn.microsoft.com/zh-cn/dotnet/csharp/language-reference/operators/conditional-operator#conditional-ref-expression
我记得我七号给微软发过report,等到我今天写这篇博客还没修正
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| int[] smallArray = [1, 2, 3, 4, 5]; int[] largeArray = [10, 20, 30, 40, 50];
int index = 7; ref int refValue = ref ((index < 5) ? ref smallArray[index] : ref largeArray[index - 5]); refValue = 0;
index = 2; ((index < 5) ? ref smallArray[index] : ref largeArray[index - 5]) = 100;
Console.WriteLine(string.Join(" ", smallArray)); Console.WriteLine(string.Join(" ", largeArray));
|
L1和L2的数组定义错误,初始化的花括号打成中括号了。