If I, for example, have this method:
IEnumerable<int> GetRandomNumbers()
{
    
    if(generationFails == true)
    {
        return Enumberable.Empty<int>(); 
    }
    return numbers;
}
In the calling method, I do:
IEnumerable<int> AddNumber(int number)
{
    var random = GetRandomNumbers();
    var randomList = random  as IList<int> ?? random.ToList(); 
    randomList.Add(number); 
    return randomList;
}
and when the generation fails, I get the exception "[NotSupportedException: Collection has a fixed size.]".
This is because Enumerable empty is an IList, so .ToList () does not start, and then I try to add Enumnable.Empty to a fixed one. I am mistaken in thinking that this is a bad design, an object that inherits IList (where Add is defined) must support Add?
Did I have to do var randomList = random.ToList()or stop using Enumberable.Empty? Is there a better way?
Update:
, . ( ) , . " , , ", , , , .
, , , . , , IList.