Lowprice低贵 2021-10-17 13:45 采纳率: 70%
浏览 20
已结题

C# if条件中有文件地址时不论真假都能执行!?

```c#

```namespace poke_text
{

public partial class Form1 : Form
{
    PictureBox[] pb;

    public Form1()
    {
        InitializeComponent();

        
    }

    private void button1_Click(object sender, EventArgs e)
    {
        int Num = 0;
        
        Num = 53;
        pb = new PictureBox[Num];
        for (int i = 1; i < Num; i++)
        {
            pb[i] = new System.Windows.Forms.PictureBox();
            pb[i].BorderStyle = BorderStyle.FixedSingle;
            pb[i].Height = 100;
            pb[i].Width = 50;
            pb[i].Image = Image.FromFile(@"C:\Users\Administrator\source\repos\poke_text\poke_text\bin\Resources\" + i + ".JPG");
            pb[i].SizeMode = PictureBoxSizeMode.StretchImage;
            flowLayoutPanel1.Controls.Add(pb[i]);
        }
    }

    private void button2_Click(object sender, EventArgs e)
    {
        int a = 2;
        
        int count = 52;

        while (a < 53)
        {
            for (a = 2; a < 53; a += 1)
            {
                int temp = a;
                for (; temp < 53; temp += a)
                {
                   ** if (pb[temp].Image!=Image.FromFile(@"C:\Users\Administrator\source\repos\poke_text\poke_text\bin\Resources\back.jpg"))
                    {
                        pb[temp].Image = Image.FromFile(@"C:\Users\Administrator\source\repos\poke_text\poke_text\bin\Resources\back.JPG");
                        Refresh();
                        count--;
                    }
                    if(pb[temp].Image==Image.FromFile(@"C:\Users\Administrator\source\repos\poke_text\poke_text\bin\Resources\back.jpg"))
                    {
                        pb[temp].Image = Image.FromFile(@"C:\Users\Administrator\source\repos\poke_text\poke_text\bin\Resources\" + temp + ".JPG");
                        count++;**
                    }                      
                }
            }
        }
        string s1 = count.ToString();
        string s2 = Convert.ToString(count);
        textBox1.Text = s2;
    }
    
    


}

}****

  • 写回答

1条回答 默认 最新

  • qq_1306620048 2021-10-18 13:48
    关注

    没明白你的问题

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

问题事件

  • 系统已结题 5月6日
  • 已采纳回答 4月28日
  • 创建了问题 10月17日

悬赏问题

  • ¥15 请问我该如何添加自己的数据去运行蚁群算法代码
  • ¥20 用HslCommunication 连接欧姆龙 plc有时会连接失败。报异常为“未知错误”
  • ¥15 网络设备配置与管理这个该怎么弄
  • ¥20 机器学习能否像多层线性模型一样处理嵌套数据
  • ¥20 西门子S7-Graph,S7-300,梯形图
  • ¥50 用易语言http 访问不了网页
  • ¥50 safari浏览器fetch提交数据后数据丢失问题
  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码