# 一天的游戏/报价 - 如何?[英] Game/Quote of the day - how to?

## 推荐答案

```var gameOfTheDay = games[(uint)(DateTime.Today.GetHashCode()) % games.Length];
```

## 其他推荐答案

```var random = new Random();
var index = random.Next(0, gameList.Count - 1);
var gameOfTheDay = gameList[index];
```

## 其他推荐答案

```var random = new Random();
int index = random.Next(list.Count);
var game = list[index];
```

### 问题描述

i have List<T> that contains games. i want to select 1 game from that list that will be the game of the day.

i have no idea on how i can do that. Please, contribute your ideas.

EDIT: Random will not work, since every page load the game will change. There are no specific limits for the game selection ( votes,rating,whatever ). There should be a connection to the date due at least thats what i have in mind.

if a random game could be select by the current date, thats the perfect solution.

## 推荐答案

```var gameOfTheDay = games[(uint)(DateTime.Today.GetHashCode()) % games.Length];
```

## 其他推荐答案

```var random = new Random();
var index = random.Next(0, gameList.Count - 1);
var gameOfTheDay = gameList[index];
```

## 其他推荐答案

Use Random.Next Method to get a random index:

```var random = new Random();
int index = random.Next(list.Count);
var game = list[index];
```

Given the list has at least one element, obviously.