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
0
votes
4 answers

get around of error 'can not resolve symbol'

how to get around this issue? i want to show toast when imageview is clicked using onclick listener. main activity.java: public class LoginActivity extends AppCompatActivity implements LoaderCallbacks { /** * Id to identity…
user5912084
0
votes
5 answers

Weird idea: C# - declare a method insinde another method

Okay, in python one can do this: def foo(monkeys): def bar(monkey): #process and return new monkey processed_monkeys = list() for monkey in monkeys: processed_monkeys += bar(monkey) return processed_monkeys (This is…
0
votes
1 answer

Cant understand this anonymous function syntax in Javascript

The following code: angular.module('socially').controller('PartiesListCtrl', function ($scope) { $scope.helpers({ parties: () => { return Parties.find({}); } }); }); demo at Angular Meteor…
aj_blk
  • 304
  • 2
  • 6
  • 16
0
votes
1 answer

C#, simplified code to handle both changes and updates of a dependency property

Obviously, I'm not an expert in C#. I would like to simplify this code by using an anonymous handler, or maybe a lambda, not sure. ValueHasChanged is a PropertyChangedCallback used when a dp is changed, it ensures the new object will be monitored…
742
  • 3,009
  • 3
  • 23
  • 18
0
votes
3 answers

Create anonymous function using generic type parameters?

Let's say I have this method: int MyMethod(int arg) { return arg; } I can create an anonymous equivalent of that like this: Func MyAnonMethod = (arg) => { return arg; }; But let's say I have a method that uses generic type…
oscilatingcretin
  • 10,457
  • 39
  • 119
  • 206
0
votes
1 answer

Trying to get VB anonymous methods working. querying lists

I am trying to get my code working as per the instruction on http://www.paulstovell.com/vb-anonymous-methods So far I have the wrapper: Public Delegate Function PredicateWrapperDelegate(Of T, A)(ByVal item As T, ByVal argument As A) As…
Phil
  • 1,811
  • 9
  • 38
  • 60
0
votes
2 answers

modify a variable in a anonymous method

I want to modify a local variable in a function of extension method. See int myvar=0; MyList.Where( x => { if (condition) myvar += 1; return false; }); return myvar; Why that is not…
Navid Farhadi
  • 3,397
  • 2
  • 28
  • 34
0
votes
3 answers

Why won't my anonymous function fire on grid.prerender?

In my gridview I have fields for inserting a new record in the footer. In my objectdatasource selecting event if no records came back I bind a single mock row to force the footer to show so they can still add records. Since the row does not contain…
adam0101
  • 29,096
  • 21
  • 96
  • 174
0
votes
1 answer

How do I wrap a property assignment in an anonymous method?

basically, I've created a custom Assert method that asserts that an exception was thrown. It's a convenience for some unit testing I'm doing Except it takes an Action as a parameter (obviously) but won't take a property assignment as an action. How…
Mark
  • 155
  • 3
  • 16
0
votes
3 answers

anonymous function variable scope [js, ajax]

$(".delete").click( function() { var thesender = this; $(thesender).text("Del..."); $.getJSON("ajax.php", {}, function(data) { if (data["result"]) $(thesender).remove(); //…
arthurprs
  • 4,457
  • 3
  • 26
  • 28
0
votes
1 answer

C# solving pseudocode to help understanding delegates&lambda

I have trouble understanding lambdas, delegates and so on, I hope with someone giving me a solution to my problem I am able to understand those better. Basically it is possible to create (or change) the body of a method when an object of the class…
Skyswimsky
  • 71
  • 2
  • 9
0
votes
1 answer

Lambda expression gives error while sending parameters while creating a new Task

I wrote the following code: int n1 = 5 Task myTask = new Task(n1 => lib.MultiplyNumberTimes2(n1)); myTask.Wait(); Console.WriteLine("Result is " + myTask.Result.ToString()); Code explanation on what I want it to do: I was expecting this…
sgarcia.dev
  • 5,671
  • 14
  • 46
  • 80
0
votes
2 answers

Naming an anonymous method for storing and removing inside a collection

Is there a possibility to name an anonymous method while still inside it? I need to do this to store the method inside a dictionary (myDict>>) and then need to remove it later on. For removing I need a reference e.g. a name…
schwarz
  • 501
  • 7
  • 28
0
votes
1 answer

Same query in stored procedure and anonymous block gives different results

The stored procedure (in Oracle) CREATE OR REPLACE PROCEDURE UPDATE_OBJ_COUNT AS BEGIN FOR v_record IN (SELECT OWNER, COUNT(*) NUM_OBJ FROM ALL_OBJECTS GROUP BY OWNER ORDER BY OWNER) LOOP DBMS_OUTPUT.PUT_LINE('***DEBUG***: Schema:…
Syam
  • 575
  • 2
  • 8
  • 25
0
votes
1 answer

Get code from overriden method in anonymous declaration

Is there a way to auto-generate code when anonymously declare a new instance of abstract class, thanks in advance. Here's is an example : My abstract class : public abstract class MySqlQueryHelperCallback { /** * * @param rs ResultSet…
Anthony Raymond
  • 7,434
  • 6
  • 42
  • 59