C
C#16mo ago
CTJ

❔ Cannot convert lambda expression to type 'Activity' because it is not a delegate type error

So I want to check if List contains element with todays date but tis error occurs: CS1660 Cannot convert lambda expression to type 'Activity' because it is not a delegate type Here is definition of class:
public class MemberStats
{
[BsonElement("userID")]
public ulong UserId { get; set; }

[BsonElement("Activity")]
public List<Activity> MessagesPerDay { get; set; }
}

public class Activity
{
public DateTime Day { get; set; }
public int Messages { get; set; }
}
public class MemberStats
{
[BsonElement("userID")]
public ulong UserId { get; set; }

[BsonElement("Activity")]
public List<Activity> MessagesPerDay { get; set; }
}

public class Activity
{
public DateTime Day { get; set; }
public int Messages { get; set; }
}
and here is where error occurs:
if (Stats.MessagesPerDay.Contains(act => act.Date == DateTime.Today))
{

}
if (Stats.MessagesPerDay.Contains(act => act.Date == DateTime.Today))
{

}
I have no idea what delegate means so9 any help would be appericiated!
9 Replies
Kouhai
Kouhai16mo ago
Contains doesn't take a delegate, use Any instead
CTJ
CTJOP16mo ago
Oh I forgot about this one Thanks!
Kouhai
Kouhai16mo ago
Np
CTJ
CTJOP16mo ago
Are we not closing those anymore?
CTJ
CTJOP16mo ago
Kouhai
Kouhai16mo ago
Despairge
Angius
Angius16mo ago
Accord is having a moment
CTJ
CTJOP16mo ago
Yea no problem, I did it by hand then lol
Accord
Accord16mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server