更快速地执行"if"语句

Doz*_*789 3 c# if-statement winforms

有没有更快的方法来做到这一点?我有36张不同的图片,当图片发生变化时,我有一个跟踪图像的字符串(旋转),image1是rotation = 1等等,我要做的就是使用36 if if这样的语句:

if (rotation == 1) //This is picture1
{

}
else if (rotation == 2) //This is picture2
{

}
Run Code Online (Sandbox Code Playgroud)

一直到:

else if (rotation == 36) //This is picture36
{

}
Run Code Online (Sandbox Code Playgroud)

有没有办法找出它只有1或2行代码的轮换?任何谁会在你问之前说检查,我已经检查过,我发现什么都没有帮助,如果你发现了什么,请在这里发布.

我的if语句内部仅用于更改图像.

谢谢.

Bri*_*new 6

要么使用数组

picture = img[i];
Run Code Online (Sandbox Code Playgroud)

或者实际上可以在索引之后命名图像(例如image01.jpg,image02.jpg等等)

该阵列让我感到最为可扩展和简洁的解决方案.