我的代码中有:
private static readonly ValueTuple<string, string>[] test = {("foo", "bar"), ("baz", "foz")};
但是当我编译我的代码时,我会得到:
TypoGenerator.cs(52,76): error CS1026: Unexpected symbol `,', expecting `)'
TypoGenerator.cs(52,84): error CS1026: Unexpected symbol `)', expecting `)'
TypoGenerator.cs(52,94): error CS1026: Unexpected symbol `,', expecting `)'
TypoGenerator.cs(52,103): error CS1026: Unexpected symbol `)', expecting `)'
TypoGenerator.cs(117,42): error CS1525: Unexpected symbol `('
TypoGenerator.cs(117,58): error CS1525: Unexpected symbol `['
如何正确创建和初始化ValueTuples的数组?
TypoGenerator.cs(53,18): error CS1026: Unexpected symbol
,', expecting)' TypoGenerator.cs(53,25): error CS1026: Unexpected symbol
)', expecting)'``` TypoGenerator.cs(54,18): error CS1026: Unexpected symbol
,', expecting)' TypoGenerator.cs(54,25): error CS1026: Unexpected symbol
)', expecting)
- Lett1new
来创建数组元素的示例吗? - Nikolay KValueTuple
名称--private static readonly (string, string)[] test = new [] { ("foo","bar"), ("baz", "foz")};
。 - Zev Spitz