When you do this
new Action(()=>methodname())
You're executing the methods. Is that really what you want?
Try something like this instead.
List<Action> actionList = List<Action>()
{
PrvoPitanje,
DrugoPitanje,
TrecePitanje
};
Random r = new Random();
while (actionList.Count() > 0)
{
int index = (actionList.Count > 1) ? r.Next(0,actionList.Count()-1) : 0;
actionList[index]();
actionList.RemoveAt(index);
}
I would also stop using
var
unless absolutely necessary. Just because the language has a given feature doesn't mean it should be used (I dislike the use of
var
- it's a personal thing).