I have some code (not writted by me) that I don’t understand:
private Func<ControllerContext, string> ThemeSelector { get; set; }
So this is not a type, this is Func < T, string > and I don’t know how this kind of thing is named but I am unable to find some explanations on Google. Does someone can gives me some explanations of giving me a link to explain?
Thanks.
Func<ControllerContext, string>is a specific type of the genericFunc<T,K>.You need to learn about generics first before you can fully understand that.
Therefore ThemeSelector is just a property of that type, which has setter and getter.
The Func type is a delegate type, which represents a function that takes one parameter of type T and returns an instance of type K.
This means that you can assign any such function to the property. E.g.:
will print “Hello world!” in the console.