Skip to content

Instantly share code, notes, and snippets.

@marzvrover
Last active November 2, 2020 22:41
Show Gist options
  • Save marzvrover/8d0503855c9d6c501a01e8b4f604430a to your computer and use it in GitHub Desktop.
Save marzvrover/8d0503855c9d6c501a01e8b4f604430a to your computer and use it in GitHub Desktop.
Randomly outputs a value from a new line separated list retrieved from stdin
using System;
using System.Collections.Generic;
namespace Marzvrover
{
class Picker
{
static void Main(string[] args)
{
string input;
List<string> list = new List<string>();
while (!string.IsNullOrEmpty(input = Console.ReadLine()))
{
list.Add(input);
}
Random index = new Random();
Console.WriteLine(list[index.Next(0, list.Count)]);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment