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 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)