Questions tagged [anonymous-delegates]

39 questions
0
votes
0 answers

How to add a SelectedValueChanging event to combobox

I need to inherit for ComboBox in order to add a new event OnSelectedValueChanging(). This event should be triggered when the user is attempting to change the current selected value of the combo box. This event also should be cancellable (the user…
Hassan Shouman
  • 275
  • 4
  • 13
0
votes
3 answers

Mapping factory methods with anonymous functions/delegates using Dictionary for faster lookup?

Currently, I have a static factory method like this: public static Book Create(BookCode code) { if (code == BookCode.Harry) return new Book(BookResource.Harry); if (code == BookCode.Julian) return new Book(BookResource.Julian); //…
randomguy
  • 12,042
  • 16
  • 71
  • 101
0
votes
1 answer

Event handling with an anonymous delegate

For the record: I found a similar question here but I have to elaborate a bit more on on the subject. My concrete scenario is this: In Silverlight 4, The myFrameworkElement.FindName("otherElementName") method seems to work fine now, but I…
herzmeister
  • 11,101
  • 2
  • 41
  • 51
0
votes
1 answer

building a tree lambda expression for generic list

I have a method through an ObjectDataSource feeds a gridview and allows sorting by column using lambda expressions: public IList GetUsers() { return new List(new[] { new UsersEntity{ UsrId =1,…
0
votes
1 answer

Lambda Expression without Argument

Assuming I have a method like this (my actual method does more—I've simplified the code here): protected void Run(Action a) { a(); } I can then call it with code like this: Run(myAction); But how would I create an inline method to pass…
Jonathan Wood
  • 65,341
  • 71
  • 269
  • 466
-1
votes
1 answer

Generic method: There's no boxing conversion from int to IComparable

I'm working on a binary search algorithm, which has the following parameters: Now when I pass these arguments: It says that type int cannot be used as a parameter F (I was under the impression that the generic types are not concerned with types that…
Vocaloidas
  • 360
  • 2
  • 17
-1
votes
1 answer

Function Delegates with Parameters c#

I'm looking for way to call Methods with Parameters using a Function Delegate. You could use the function delegate in the place instead of calling processOperationB. but looking for any way that the below way can be achieved. public class…
vonbalaji
  • 249
  • 2
  • 10
-2
votes
2 answers

Why do anonymous delegates appear faster than regular delegates?

Can somebody tell me why anonymous delegates runs a lot faster than regular delegates? I saw the result in diagnosing with Stopwatch class in a for loop and the difference was significant. If you run the below code in normal delegate, it runs alot…
Diggie
  • 142
  • 3
  • 10
-4
votes
1 answer

AnonymousDelegate help for c#

I need help with this ParallelOptions parallelOption = new ParallelOptions() { MaxDegreeOfParallelism = 1000 }; Parallel.ForEach(strs, parallelOption, (string a0, ParallelLoopState a1, long a2) => new VB$AnonymousDelegate_0
Jimmy
  • 1
1 2
3