• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 383
  • Last Modified:

"Nested Methods / Functions" - C#

Hi,

Can you please provide me simple examples on:

"Nested Methods / Functions" - C#

Thanks
0
milani_lucie
Asked:
milani_lucie
  • 3
  • 3
1 Solution
 
anarki_jimbelCommented:
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now