© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
11 replies
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
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!
image.png
image.png
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ Delegate vs lambda function/expression
C#CC# / help
11mo ago
❔ What is this notation? Is it a lambda expression?
C#CC# / help
4y ago
Assigning Lambda to Delegate (PurposesReason)
C#CC# / help
4y ago