Я могу его написать при возврате значения из метода или свойства. Но я не могу написать это при объявлении переменной.
Код: Выделить всё
internal class Program
{
private static (int, int) getVal1 => (1, 2);
private static (int, int) getVal2 => new(3, 4);
private static (int, int) getVal3() { var v = new(5, 6); return v; }
// Error CS8754 There is no target type ... ^^^^^^^^^
static void Main(string[] args)
{
Console.WriteLine(getVal1);
Console.WriteLine(getVal2);
Console.WriteLine(getVal3());
}
}
Подробнее здесь: https://stackoverflow.com/questions/786 ... or-is-it-a