-2

所以我的朋友让我制作一个胸部程序,它只是一个显示随机图像的程序,长话短说在这个程序中我有 5 张图像我需要知道如何做的是 1)让第 4 种形式显示随机我已经将 5 张图片中的图片全部转换为 .png 到单个图片框 2)我在那里有一个按钮,所以当我点击它时,它会在同一个图片框中显示一个新图片

我有什么:一个空白的图片框,一个按钮,一个windows窗体,以及资源文件中的5张图片

所有这些都是在 c# 中的 Visual Studio 2019 中制作的,也请善待,因为这是我自高中以来的第一个编码项目(2017 年毕业),所以我对事情有点生疏了 XD 谢谢你的任何帮助!

4

1 回答 1

0

You could add the pictures in an IEnumerable and shuffle them after each button click and then display the first item of the IEnumerable.

The code would look something like this.

var shuffledImages= images.OrderBy(a => Guid.NewGuid()).ToList();
boxImage4 = shuffledImages.First();
于 2020-05-10T02:23:29.753 回答