© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
30 replies
Saiyanslayer

✅ Using Params with Pattern Matching Switch statement

I have the following enums:
public enum SearchFilters {
    None,
    Active,
    Overdue,
    Archived
}
public enum SearchFilters {
    None,
    Active,
    Overdue,
    Archived
}


I want to link a modification to a query based on which enum you select by switch statement pattern matching:
public static class FilterExtensions {
    public static IQueryable Filter(this IQueryable query, params SearchFilters[] filters) => filters switch {
        [] => query,

        _ => query,
    };
}
public static class FilterExtensions {
    public static IQueryable Filter(this IQueryable query, params SearchFilters[] filters) => filters switch {
        [] => query,

        _ => query,
    };
}


I can't find a syntax that works with the params keyword. I could do a foreach, but I'm tryign to improve my knowledge.

Is there a way to parse a switch pattern matching using an array of inputs?
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

✅ Switch pattern matching with integers
C#CC# / help
3y ago
❔ alternative to switch statement or if statements?
C#CC# / help
4y ago
Switch statement dont work with variables
C#CC# / help
2y ago