У меня есть векторный класс с двумя методами деконструкции следующим образом:
public readonly struct Vector2
{
public readonly double X, Y;
...
public void Deconstruct( out double x, out double y )
{
x = this.X;
y = this.Y;
}
public void Deconstruct( out Vector2 unitVector, out double length )
{
length = this.Length;
unitVector = this / length;
}
}
Где-то еще у меня есть:
Vector2 foo = ...
(Vector2 dir, double len) = foo;
Это дает мне:
CS0121: The call is ambiguous between the following methods or properties: 'Vector2.Deconstruct(out double, out double)' and 'Vector2.Deconstruct(out Vector2, out double)'
Как это неоднозначно?
Редактировать: вызов Deconstruct вручную работает нормально:
foo.Deconstruct( out Vector2 dir, out double len );