Questions tagged [anonymous-methods]

An anonymous method is a procedure or function that does not have a name associated with it.

An anonymous method is a procedure or function that does not have a name associated with it. An anonymous method treats a block of code as an entity that can be assigned to a variable or used as a parameter to a method. In addition, an anonymous method can refer to variables and bind values to the variables in the context in which the method is defined. They are similar to the construct of closures defined in some languages.

An anonymous method in C# is a way to pass a code block as a delegate parameter.

320 questions
-1
votes
1 answer

How to count in anonymous method?

I have this an implementation of class IntList. I'm am supposed to: Use the capability of the anonymous methods to refer to a local variable in their enclosing method and the defined "Act"-method to compute the sum of an IntList’s elements (without…
-1
votes
2 answers

How can I create anonymous method in a lambda expression using C# like I can in VB.NET?

In VB.NET, I can do this: MyArray.Select(Function(a) Dim x as string x = a Return x End Function) How can I do this in c#?
oscilatingcretin
  • 10,457
  • 39
  • 119
  • 206
-2
votes
4 answers

How can I pass a function as a parameter?

I want to know if is there any way to pass a function to another function to handle its try/catch. I am working on an existing codebase that does not have any Exception handling.
Mayank
  • 1,351
  • 5
  • 23
  • 42
-2
votes
1 answer

Handling asynchronous anonymous method errors

I have a base framework designed to deal with errors generically; however, when the error occurs, I appear to not be catching it in my framework. The following code is a simplified version of what I'm trying to achieve: class Program { static…
Paul Michaels
  • 16,185
  • 43
  • 146
  • 269
-2
votes
1 answer

Pass parameter to anonymous method?

I have the following method : while (TryCount < 2) { Lock.Try(inCommandObj.Connection, _timeout, delegate(DataSet ds) { dataAdapter = new OdbcDataAdapter(inCommandObj); returningObj = dataAdapter.Fill(ds); …
Ivy
  • 2,285
  • 4
  • 24
  • 29
1 2 3
21
22