Return the collection instead Tuple<>
public IEnumerable<int> movepion(schaken.pion pion, int row, int column)
{
IEnumerable<int> result;
bool return2Items = false;
if(return2Items)
result = new List<int> { 1, 2 };
else
result = new List<int> { 1, 2, 3 };
return result;
}
After a better understanding of the comments, which I recommend creating an object MoveOption, and that the function will returnIEnumerable<MoveOption>
public class MoveOption
{
public int X { get; set; }
public int Y { get; set; }
}
Then in your function:
public IEnumerable<MoveOption> movepion(schaken.pion pion, int row, int column)
{
List<MoveOption> options = new List<MoveOption>();
if()
{
options.Add(new MoveOption{ X = 1, Y = 2 });
}
if()
{
options.Add(new MoveOption{ X = 5, Y = 7 });
}
return options;
}
, , :
public interface IMoveOptionCalcumator
{
public MoveOption Calculate();
}
public class MoveOptionX : IMoveOptionCalcumator
{
public MoveOption Calculate() { }
}
:
public class YourClass
{
public IEnumerable<IMoveOptionCalcumator> MoveOptionCalculators { get; set; }
public YourClass()
{
}
public IEnumerable<int> movepion(schaken.pion pion, int row, int column)
{
List<MoveOption> options = new List<MoveOption>();
foreach (var item in MoveOptionsCalculators)
{
var result = item.Calculate();
if(result != null)
{
options.Add(result);
}
}
return options;
}
}