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

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

I am not familar with this, please explain.

Thanks,
newbieweb
0
newbieweb
Asked:
newbieweb
  • 3
  • 2
2 Solutions
 
rajvjaCommented:
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
 
nmarunCommented:
Read http://www.codeproject.com/KB/cs/DelegatesOMy.aspx for a detailed article on lambda expressions.

Arun
0
 
newbiewebSr. Software EngineerAuthor Commented:
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
Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

 
newbiewebSr. Software EngineerAuthor Commented:
Is Func a delegate
0
 
nmarunCommented:
Yes it is... read the article I posted.. it'll tell you all you need to know about 'Func'.

Arun
0
 
newbiewebSr. Software EngineerAuthor Commented:
Thanks.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Microsoft Exchange Server

The MCTS: Microsoft Exchange Server 2010 certification validates your skills in supporting the maintenance and administration of the Exchange servers in an enterprise environment. Learn everything you need to know with this course.

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