Solved

"Nested Methods / Functions" - C#

Posted on 2012-03-26
7
361 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
  • 3
  • 3
7 Comments
 
LVL 29

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

911 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now