You can see this article for example : How and Why to Use Delegates in C#
What problem does Func solve?
I'm struggling to understand when and why I would use Func and what problem does it resolve?
I've read MSDN, tutorials teacher etc etc but all have examples but not necessarily explaining what problem it could resolve or when I could/should use it?
Could anyone give a very simple example(s) to demo this please?
Developer technologies C#
2 answers
Sort by: Most helpful
-
-
Karen Payne MVP 35,586 Reputation points Volunteer Moderator
2021-07-23T16:08:05.513+00:00 Another usage for projections.
Let's say you want to return a custom list as shown here from this model/class, we define a class as follows and shown below.
Func receives a Customer and returns a CustomerEntity. If this as a ASP.NET we would use mapping such as auto-mapper instead for CRUD, here it's in a desktop app working with Entity Framework Core.
Also, when using LINQ/Lambda, Select, Where they use Func also as a predicate. Hover over a Select to see it. Also, read the docs and search for Func here