Solved

"Nested Methods / Functions" - C#

Posted on 2012-03-26
7
366 Views
Last Modified: 2012-03-27
Hi,

Can you please provide me simple examples on:

"Nested Methods / Functions" - C#

Thanks
0
Comment
Question by:milani_lucie
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
7 Comments
 
LVL 30

Accepted Solution

by:
anarki_jimbel earned 500 total points
ID: 37768489
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
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37768543
_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
 

Author Comment

by:milani_lucie
ID: 37768628
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!

 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37768637
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
 

Author Comment

by:milani_lucie
ID: 37768777
Kaufmed,

If a function does not return a value then

Func< >

How to declare this ?

Thanks
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37769227
Use Action.
0
 

Author Comment

by:milani_lucie
ID: 37771320
Got it. Thanks a lot.
0

Featured Post

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question