Click here to Skip to main content
15,890,186 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi all,

Could you please provide the features of C# Func?

Thanks in advance.
Posted
Updated 23-May-12 23:31pm
v3
Comments
Sergey Alexandrovich Kryukov 24-May-12 2:35am    
Incorrect question.
--SA

Should I even explain why this is an incorrect question? (Please see my comment to the question.)

Types do not have "advantages" or "disadvantages", they do or do not fit certain purposes. The identifier Func is not a type; this is a set of different but similar generic types. Please see:
http://msdn.microsoft.com/en-us/library/system.aspx[^].

See also Action generic delegates on the same page. The help pages on two simplest generic types Func and two simplest generic types Action contain well annotated code samples.

Browse to their definitions or see their descriptions to see what is it. The purpose of these type is sheer convenience; few generic delegate signatures which are more likely to be used then others are predefined. Anyone could define those generic or non-generic type where they are required, without any problems or losses.

What you really need is some understanding of how to ask questions. Please see this discussion:
How to ask a good question?[^].

You are recommended to review some rules:
Code Project Questions and Answers FAQ[^]
How to Use Google and Other Tips for Finding Programming Help[^]
Some guidelines for posting questions in the forums[^].

Good luck,
—SA
 
Share this answer
 
v2
You might have a look this Tips Invoke a ASP.NET page method from a User Control[^].

Note: In the Tips, Action has been used but you could use Func as well by little change.

This could be give you a direction of the Usage of the Action or Func in Asp.Net.

Hope it helps :)
 
Share this answer
 
It's not ASP.NET specific instead it's a C# thingy.

You can use this delegate to represent a method that can be passed as a parameter without explicitly declaring a custom delegate.

Details here: MSDN: Func<t,> Delegate[^]
Samples are given in the documentation. You can use it as per your need.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900