Solved

What does "Func<string, int> method = Work;" do?

Posted on 2010-08-19
6
252 Views
Last Modified: 2013-12-17
I am not familar with this, please explain.

Thanks,
newbieweb
0
Comment
Question by:newbieweb
[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
  • 2
6 Comments
 
LVL 11

Accepted Solution

by:
rajvja earned 250 total points
ID: 33473530
Hi,

   Func is the function name
  It will take 2 parameters. 1. string value, 2. integer value

It is like GetFirstName('abc def',3) = abc

0
 
LVL 27

Assisted Solution

by:nmarun
nmarun earned 250 total points
ID: 33473546
Read http://www.codeproject.com/KB/cs/DelegatesOMy.aspx for a detailed article on lambda expressions.

Arun
0
 

Author Comment

by:newbieweb
ID: 33473579
It's used here:

static void Main()
{
  Func<string, int> method = Work;
  method.BeginInvoke ("test", Done, method);
  // ...
  //
}
 
static int Work (string s) { return s.Length; }
 
static void Done (IAsyncResult cookie)
{
  var target = (Func<string, int>) cookie.AsyncState;
  int result = target.EndInvoke (cookie);
  Console.WriteLine ("String length is: " + result);
}
0
Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

 

Author Comment

by:newbieweb
ID: 33473588
Is Func a delegate
0
 
LVL 27

Expert Comment

by:nmarun
ID: 33473598
Yes it is... read the article I posted.. it'll tell you all you need to know about 'Func'.

Arun
0
 

Author Closing Comment

by:newbieweb
ID: 33473640
Thanks.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

691 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