I know that the method is returning List<string> at the moment. But in some (which occur quite frequently in our application) scenarios, it returns List having only one string.
So eventually it would return either string or List<string>.
Since it’s unpredictable what it’ll return at run time, at present it’s return type is kept as object.
What alternative approach could be used to avoid method returning object?
EDIT:
I would like to have answer to the question What alternative approach could be used to avoid method returning object? ; without considering the scenario I described. List is enough here.
why return a
string? aList<string>with a singlestringin it is perfectly well defined… use that! An ambiguous API is silly here.Another option might be
IEnumerable<string>, but… meh, just return the list with a singlestring!