日期:2014-05-17  浏览次数:20712 次

9乘9 个 picturebox, 判断左右相邻的图片是否一致,若一致则清空
9乘9 个 picturebox, 判断左右相邻的图片是否一致,若一致则清空(图片是从imagelist里边随机赋给picturebox的)
for (int i = 0; i < check.Length; i++)
            {
                List<Check> list = new List<Check>();
                if (i % 9 < 8 && list[i].Picturebox.Image == list[i + 1].Picturebox.Image== list[i + 2].Picturebox.Image)//索引超出范围。必须为非负值并小于集合大小。参数名: index这里没有超出啊,怎么回事。一整天就想这了
                {
                    list[i].Picturebox.Image = null;
                    list[i + 1].Picturebox.Image = null;
                }
picturebox 索引超出范围 List

------解决方案--------------------
for (int i = 0; i < check.Length; i++)
{
    if (i%9 < 8 && check[i].Picturebox.Image == check[i + 1].Picturebox.Image)
    {
        check[i].Picturebox.Image = null;
        check[i + 1].Picturebox.Image = null;
    }
}

------解决方案--------------------

C# 连连看游戏算法,可任意设置N X N 格子
------解决方案--------------------
这是手机"消灭星星"的游戏,玩起来简单,用代码实现可能不是那么容易了