Generating a list of unique random longs I'm using the
Bogus for .NET: C#, F#, and VB.NET library.
What would be a more efficient way to generate a list of unique random longs?
public IEnumerable&lt;long&gt; GenerateRandomNumbers(int count = 1)
{
      var f = new Faker();
      List&lt;long&gt; temporaryList = new List&lt;long&gt;();
                
      for (int i = 0; i &lt; 10000; i++)
      {                
          var number = f.Random.Long(5000000000, 8000000000);
          temporaryList.Add(number );
      }
    
      return temporaryList.Distinct().Take(count).ToList();
}
I doubt that algorithmic efficiency can be improved but you may consider an implementation similar to this which leverages idiomatic LINQ.
public IEnumerable&lt;long&gt; GenerateRandomNumbers()
{
    var f = new Faker();

    return 
        Enumerable.Range(0, int.MaxValue)
        .Select(
            _ =&gt; f.Random.Long(5000000000, 8000000000))
        .Distinct();
}