© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
104 replies
Emelie

❔ Help me understand this lambda expression

var myKey = availableProducts.FirstOrDefault(x => x.Value == input).Key;
Console.WriteLine("Quantity: left " + myKey);
Im trying to understand how this code works (how it gets the key for the input value in a dictionary). Been searching the web but not really getting more clear.. mostly I dont understand the use of "x". Many thanks for any help!
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
Next page

Similar Threads

LINQ Lambda-Expression Diff
C#CC# / help
4y ago
✅ Can someone help me understand this?
C#CC# / help
2w ago
Please help me to understand this:
C#CC# / help
2y ago
please help me understand this warning
C#CC# / help
2y ago