I have a property in a class that is a sequence of items, like:
private LinkedList<T?> valueHistory = new ();
public IEnumerable<T?> ValueHistory
{
get => valueHistory;
}
public T? CurrentValue
{
get => valueHistory.LastOrDefault();
set => valueHistory.AddLast(value);
}
This works, but I want to communicate to a consumer that the value history is in sequence, which (if I understand correctly) I don’t think IEnumerable
does?
And I want to be free to change the backing field from a LinkedList to a List, or an array, or anything else that makes more sense later.
What type do I declare ValueHistory
as to indicate that the consumer can rely on the sequence of values being correct?
5