© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•15mo ago•
9 replies
SWEETPONY

Is it possible to use pattern matching here?

I want smth like this:
var isInbound = entity.LegData!.Location.LatestArrivalStationIataCode == "SVO";
var isOutbound = entity.LegData!.Location.LatestDepartureStationIataCode == "SVO";

return new PresentationModel
{
     Terminal = 
         isInbound => entity.LegData!.Location.ArrivalTerminal
         isOutbound => entity.LegData!.Location.DepartureTerminal
}
var isInbound = entity.LegData!.Location.LatestArrivalStationIataCode == "SVO";
var isOutbound = entity.LegData!.Location.LatestDepartureStationIataCode == "SVO";

return new PresentationModel
{
     Terminal = 
         isInbound => entity.LegData!.Location.ArrivalTerminal
         isOutbound => entity.LegData!.Location.DepartureTerminal
}
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

✅ Is it possible to use grouping here?
C#CC# / help
3y ago
✅ Is it worth to use stackalloc here?
C#CC# / help
16mo ago
Pattern matching `Type` in a way that can be assigned to a `const` variable... is it possible?
C#CC# / help
2y ago
✅ Is it possible to use nameof in attributes?
C#CC# / help
3y ago