Solved

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

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

Thanks,
newbieweb
0
Comment
Question by:newbieweb
  • 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Delivering innovative fully-managed cloud services for mission-critical applications requires expertise in multiple areas plus vision and commitment. Meet a few of the people behind the quality services of Concerto.
Need to grow your business through quality cloud solutions? With everything required to build a cloud platform and solution, you may feel like the distance between you and the cloud is quite long. Help is here. Spend some time learning about the Con…

929 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

13 Experts available now in Live!

Get 1:1 Help Now