From the course: Advanced C#: Functional Programming Patterns

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Use Func<T> for first-class functions

Use Func<T> for first-class functions - C# Tutorial

From the course: Advanced C#: Functional Programming Patterns

Use Func<T> for first-class functions

- [Instructor] Since functions are such a key part of functional programming, we should spend a few minutes talking about how to work with them in C Sharp. In functional programming, we use them in variables, we store functions in dictionaries and collections, we work with them as parameters into a function, we can even create higher order functions that return a function from the method call. In C Sharp, there are three main ways of representing functions. Methods, delegates, and Lambda expressions. Of these three, the delegate and the Lambda expression are the most useful in functional programming. Delegates have been around forever in dot net. In recent years, Microsoft has created a number of generalized delegates that are useful, so you typically don't have to create your own custom delegates anymore. And the two that are most used in functional programming is func of t, and action of t. Now func of t takes some…

Contents