I'm working on a little practice project for myself and I'm trying to call this extension method in my tests
var days = account.Transactions.PassDays(10, Today);
which gives me this error
CS1929 'List<Transaction>' does not contain a definition for 'PassDays' and the best extension method overload 'PassTime.PassDays(List<Event>, int, DateTime)' requires a receiver of type 'List<Event>'
The using statement is highlighted, the extension method is declared as
public static IEnumerable<Day> PassDays(this List<Event> events, int daysToPass, DateTime startTime)
The List I'm trying to use it on is of a class that derives from the Event class. Everything I've read suggests this should work.
public record Transaction : Event
public record Event : IEvent
CodePudding user response:
using
public static IEnumerable<Day> PassDays(this IEnumerable<IEvent> events, int daysToPass, DateTime startTime)
fixed this. (IEvent
was not necessary for this but I made the change in anticipation of it being more useful) maybe someone else can explain why this worked.