1,931 questions
Use Random to randomly select a value. Suppose you have 3 characters to choose from. Then you'd do something like this.
//Do this once at startup of your app or when creating the instance that handles the random logic
var random = new Random();
//Select 1 of 3
var selectedValue = random.Next(1, 4);
This would give all 3 equal chances of selection. Just wrap that code in the Click
handler of the button (or in a helper type depending upon your app needs).
private void OnSelectCharacter ( object sender, EventArgs e )
{
//Assume the characters are stored in an array called _characters
//Select a random index of the available characters
var selectedIndex = random.Next(0, _characters.Length);
//Get the selected character
var selectedCharacter = _characters[selectedIndex];
}