Get random element from hashset?
c#, hashset, random
Solution
Random randomizer = new Random();
string[] asArray = hashs.ToArray()
string randomLine = asArray[randomizer.Next(asArray.length)];
Problem
Im using the following piece of code to load my text file into a hashset. ``` HashSet<string> hashs = new HashSet<string>(File.ReadLines("textFile.txt")); ``` Am wondering if there is any easy way to get a random line from it? Lets asume the textFile.txt contains 10 lines, i would like to randomize and grab one of those existing lines.