anonymous-methods Questions

6

Solved

Why can't you pass an anonymous method as a parameter to the BeginInvoke method? I have the following code: private delegate void CfgMnMnuDlg(DIServer svr); private void ConfigureMainMenu(DIServe...
Sturdy asked 17/6, 2009 at 14:35

7

With the advent of new features like lambda expressions (inline code), does it mean we dont have to use delegates or anonymous methods anymore? In almost all the samples I have seen, it is for rewr...
Coccidioidomycosis asked 19/9, 2008 at 23:14

2

Solved

Is there a workaround to update a ref parameter inside an anonymous method? I know that the an anonymous method doesn't allow access to ref parameters of the outer scope, but is there another way ...
Shae asked 13/5, 2014 at 12:4

2

On Chris's blog: http://delphihaven.wordpress.com/2011/07/14/weird-in-more-ways-than-one/ I found the following code type TLinkVisitor<T> = reference to procedure(const Item: T); TDoubl...
Radiate asked 4/5, 2014 at 21:13

1

Solved

I was reading this in the MSDN documentation on Anonymous Methods (C# Programming Guide), but I do not understand the part about omitting the parameter list. It says: There is one case in ...
Draper asked 7/4, 2014 at 21:6

3

Solved

this is a constructed example. I don't want to post the original code here. I tried to extract the relevant parts though. I have an interface that manages a list of listeners. TListenerProc = ref...

2

Solved

A function is returning an anonymous function. I would like to assign the result to a variable. However the compiler thinks that I am trying to assign the function and not the result of the functio...

9

A lot of questions are being answered on Stack Overflow, with members specifying how to solve these real world/time problems using lambda expressions. Are we overusing it, and are we co...
Meghannmegiddo asked 23/3, 2009 at 10:49

4

Solved

If I had this anonymous method I should declare x variable as final. private void testMethod (ListField<BeanModel> listField){ final ListLoader<BeanModel> loader = new PagedLi...
Sianna asked 14/8, 2013 at 11:46

3

Solved

In Delphi XE, the following code will cause memory leak: procedure TForm1.Button1Click(Sender: TObject); var P, B: TProc; begin B := procedure begin end; P := procedure begin B; end; end; ...
Elation asked 8/6, 2011 at 1:42

3

Solved

Can anyone provide a concise distinction between anonymous method and lambda expressions? Usage of anonymous method: private void DoSomeWork() { if (textBox1.InvokeRequired) { //textBox1...
Hewitt asked 17/7, 2013 at 19:53

2

Solved

In ASP.NET MVC 4 project, I have a model for join (with payload): public class LeagueMember { [Key, Column(Order = 0)] public int MemberId { get; set; } [Key, Column(Order = 1)] public int Le...
Morbidity asked 26/4, 2013 at 2:50

1

Solved

Having read in article "Anonymous Methods" (as part of the articles series "Delegates and Lambda Expressions in C# 3.0") the phrase: "Advanced Topic: Parameterless Anonymous Methods ... anonym...
Gamely asked 13/2, 2013 at 8:20

4

Solved

I am new in the functional side of C#, sorry if the question is lame. Given the following WRONG code: var jobSummaries = from job in jobs where ... select new { ID = job.ID, Description = j...
Unjaundiced asked 3/3, 2010 at 13:17

2

Solved

See the following code: public abstract class Base { public virtual void Foo<T>() where T : class { Console.WriteLine("base"); } } public class Derived : Base { public override void Fo...
Agnew asked 10/10, 2012 at 6:49

3

Solved

Title kinda says it all. The usual SOS command !bpmd doesn't do a lot of good without a name. Some ideas I had: dump every method, then use !bpmd -md when you find the corresponding MethodDesc ...
Justiciable asked 12/3, 2010 at 6:33

4

Solved

I hope I worded the title of my question appropriately. In c# I can use lambdas (as delegates), or the older delegate syntax to do this: Func<string> fnHello = () => "hello"; Conso...
Anaerobic asked 22/4, 2010 at 2:47

2

Solved

What I want to do: I have a few objects in a genric list. I want to capture each of this object in anonymous method and execute this method as a separate OTL Task. This is a simplified example: ...

2

Solved

This is C# 4.0. I have a class that stores WeakReferences on some Actions like that: public class LoremIpsum { private Dictionary<Type, List<WeakReference>> references = new Dictiona...
Landed asked 6/10, 2012 at 8:21

4

Solved

When using lambda expressions or anonymous methods in C#, we have to be wary of the access to modified closure pitfall. For example: foreach (var s in strings) { query = query.Where(i => i.Pro...
Saari asked 17/1, 2012 at 17:21

8

Solved

I tried the following code in LINQPad and got the results given below: List<string> listFromSplit = new List<string>("a, b".Split(",".ToCharArray())).Dump(); listFromSplit.ForEach(dele...
Wagram asked 15/10, 2008 at 16:0

10

Solved

I develop and maintain a large (500k+ LOC) WinForms app written in C# 2.0. It's multi-user and is currently deployed on about 15 machines. The development of the system is ongoing (can be thought o...
Playroom asked 5/10, 2010 at 15:57

2

Solved

What is the scope of local variable declared in Linq Query. I was writing following code static void Evaluate() { var listNumbers = Enumerable.Range(1, 10).Select(i => i); int i = 10; } ...
Transhumance asked 9/5, 2012 at 14:16

2

Solved

I want to assign a function implementation dynamically. Let's start with the following: class Doer(object): def __init__(self): self.name = "Bob" def doSomething(self): print "%s got it do...
Leary asked 29/4, 2012 at 17:58

1

Solved

Given the following sample codes: static void SomeMethod() { Action<int,int> myDelegate; //... myDelegate = delegate { Console.WriteLine( 0 ); }; myDelegate = delegate() { Console.Writ...
Nitid asked 19/4, 2012 at 4:13

© 2022 - 2024 — McMap. All rights reserved.