我有一个功能...
var neighbours =
from x in Enumerable.Range(0, array2.GetLength(0))
.Where(x => Math.Abs(x - refx) <= 1)
from y in Enumerable.Range(0, array2.GetLength(1))
.Where(y => Math.Abs(y - refy) <= 1)
select new { x, y };
neighbours.ToList().ForEach(Console.WriteLine);
这个函数运行良好。但我想要:
var neighbours =
from x in Enumerable.Range(0, array2.GetLength(0))
.Where(x => Math.Abs(x - refx) <= 1)
from y in Enumerable.Range(0, array2.GetLength(1))
.Where(y => Math.Abs(y - refy) <= 1)
select new { x, y };
neighbours.ToList().ForEach(label3.Text);
它不起作用。所以,我想将 System.Action 转换为字符串......对此有什么想法吗?