"Nested Methods / Functions" - C#

Hi,

Can you please provide me simple examples on:

"Nested Methods / Functions" - C#

Thanks
milani_lucieAsked:
Who is Participating?
 
anarki_jimbelConnect With a Mentor Commented:
I was thinking to give my examples but decided it would be better if you read the following discussions:
http://stackoverflow.com/questions/1919372/nested-methods-why-are-they-useful

http://www.go4expert.com/forums/showthread.php?t=3853
0
 
käµfm³d 👽Commented:
_NO POINTS_

anarki_jimbel's first link is perfect (I think). Specifically (in case you don't see it), you are passing behaviors around rather than just simply data. I hadn't really ever thought of it that way, but now that I hear it it sounds spot on.
0
 
milani_lucieAuthor Commented:
Hi,

Func<int, int>

means function takes "int" type of data and returns "int" type of data. Am i correct ?

Thanks
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
käµfm³d 👽Commented:
It took me a while to understand this, but yes:  the last T is the type of the result; all other Ts in a type list are the types of the parameters to the delegate. So a Func<string, int, char, double> would return a double, and it would take three parameters:  a string, an int, and a char.
0
 
milani_lucieAuthor Commented:
Kaufmed,

If a function does not return a value then

Func< >

How to declare this ?

Thanks
0
 
käµfm³d 👽Commented:
Use Action.
0
 
milani_lucieAuthor Commented:
Got it. Thanks a lot.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.