我目前正在开发一款控制台问答游戏,为此我需要从二维数组的随机类别中选择随机问题。但我不确定如何从二维数组中随机选取。
我无法显示我的完整阵列,因为它们非常大 - 下面是修剪后的版本:
string[,] mineKategorier = new string[10, 6]
{
{"C#","Question one here", "Question two here", "Question three here"},
{"Spil engines", "Question one here", "Question two here", "Question three here"},
{"Sport", "Question one here", "Question two here", "Question three here"},
};
Random rnd = new Random();
int row = rnd.Next(mineKategorier.GetLength(0));
int column = rnd.Next(mineKategorier.GetLength(1));
string randomKategori = mineKategorier[row, column];
我是一名优秀的程序员,十分优秀!