私は、この質問の問題のバージョンがかなり頻繁に聞かれることを知っていますが、最後の日のフォーラムを見て、Fisher-Yatesシャッフルを実装しようとしましたが、 Entscheidungsfragen.Shuffle(this System.Collections.Generic.IList) ':エクステンションメソッドは非ジェネリックな静的クラスで定義されていなければなりません。c#randomizeリスト<action>
private static System.Random rng = new System.Random();
public static void Shuffle<T>(this IList<T> list)
{
int n = list.Count;
while (n > 1) {
n--;
int k = rng.Next(n + 1);
T value = list[k];
list[k] = list[n];
list[n] = value;
}
}
private static void CreateList(string[] args)
{
var scenes =new List<Action>(szene1, szene2);
scenes.Shuffle();
foreach (Action sce in scenes)
sce();
}
誰かが私を助けることができれば - 私はちょうど私が私が見つけたすべてのものを試してみました原因を失って以来、I'dは本当に、感謝しています。
です'CreateList'からアクセス可能です。 –