anonymous-methods Questions
2
Solved
I tried to use Delphi's syntax for anonymous methods:
type
fun = reference to function(): Integer;
Fpc shows a syntax error:
Error: Identifier not found "reference"
What's the Free Pascal eq...
Aleron asked 17/10, 2011 at 20:19
9
Solved
Having a bit of trouble with the syntax where we want to call a delegate anonymously within a Control.Invoke.
We have tried a number of different approaches, all to no avail.
For example:
myCont...
Caravel asked 31/10, 2008 at 10:49
3
Solved
In JavaScript, it's not uncommon to see self-invoking functions:
var i = (function(x) {
return x;
})(42);
// i == 42
While I'm certainly not comparing the languages, I figured such a construct...
Gynecoid asked 7/3, 2013 at 18:29
8
Solved
Basically I have an anonymous method that I use for my BackgroundWorker:
worker.DoWork += ( sender, e ) =>
{
foreach ( var effect in GlobalGraph.Effects )
{
// Returns EffectResult
yield re...
Gastight asked 23/3, 2011 at 21:8
14
Solved
Is it possible to unsubscribe an anonymous method from an event?
If I subscribe to an event like this:
void MyMethod()
{
Console.WriteLine("I did it!");
}
MyEvent += MyMethod;
I can un-subscr...
Magnanimity asked 8/10, 2008 at 15:24
3
Solved
Anonymous methods are essentially interfaces with an Invoke method:
type
TProc = reference to procedure;
IProc = interface
procedure Invoke;
end;
Now, is there a possibility to assign them ...
Plosion asked 8/7, 2013 at 18:19
5
Solved
So, every time I have written a lambda expression or anonymous method inside a method that I did not get quite right, I am forced to recompile and restart the entire application or unit test framew...
Chromonema asked 24/2, 2009 at 14:38
5
Solved
I have some linq to sql method and when it does the query it returns some anonymous type.
I want to return that anonymous type back to my service layer to do some logic and stuff on it.
I don't k...
Jaborandi asked 20/12, 2009 at 22:24
8
Solved
I would like to know if there is any overhead incurred through the use of anonymous methods when creating a Background worker.
for example:
public void SomeMethod()
{
BackgroundWorker worker = n...
Jordain asked 22/2, 2012 at 12:41
6
Solved
I instantiated an object of an anonymous class to which I added a new method.
Date date = new Date() {
public void someMethod() {}
}
I am wondering if it is possible to call this method from o...
Authentic asked 20/3, 2013 at 15:16
5
Solved
I thought it would be nice to do something like this (with the lambda doing a yield return):
public IList<T> Find<T>(Expression<Func<T, bool>> expression) where T : class, ...
Snuffle asked 1/8, 2009 at 23:10
5
Solved
I thought it would be nice to do something like this (with the lambda doing a yield return):
public IList<T> Find<T>(Expression<Func<T, bool>> expression) where T : class, ...
Gaberdine asked 1/8, 2009 at 23:10
6
Solved
Once it is compiled, is there a difference between:
delegate { x = 0; }
and
() => { x = 0 }
?
Petroglyph asked 18/11, 2008 at 18:38
1
Solved
I would like to use the naming feature of ValueTuple as follows:
IEnumerable<(string, char, int)> valueTuples = new(string, char, int)[]
{
("First", '1', 1),
("Second", '2', 2),
("Third...
Olli asked 28/4, 2018 at 4:11
1
For a piece of code that needs the type "family" of a generic type, I try to use the TypeInfo to retrieve the required information.
class function GetTypeKind<T>:TTypeKind;
For most types ...
Stinkstone asked 20/4, 2018 at 22:33
2
Solved
Why the C# 7 Compiler turns Local Functions into methods within the same class where their parent function is. While for Anonymous Methods (and Lambda Expressions) the compiler generates a nested c...
Harijan asked 26/7, 2017 at 21:45
6
Solved
Is there an equivalent to the continue statement in ForEach method?
List<string> lst = GetIdList();
lst.ForEach(id =>
{
try
{
var article = GetArticle(id);
if (article.author.contains...
Gouty asked 30/11, 2011 at 21:49
5
Solved
I'm new to SO and programming and learning day by day with bits and pieces of tech (C#) jargons.
After Googling for a while, below is what I've researched about methods
A Method is a block of st...
Indefatigable asked 1/1, 2014 at 13:54
1
Solved
I am trying to make list of event handlers where handler is method reference.
To delete specific handler i need to find it in the list.
But how can i compare code address of two method references?
...
Calumniate asked 26/10, 2016 at 11:18
2
Solved
Does Delphi "instantiate" each anonymous method (like an object)?, if so when does Delphi create this instance, and most important, when does Delphi free it?
Because anonymous method also capture...
Ogata asked 10/10, 2016 at 9:20
1
In this sample console app:
class Program
{
static void Main()
{
DoAsyncFoo();
Console.ReadKey();
}
private static async void DoAsyncFoo()
{
var task = CollectStatsAsync();
dynamic foo =...
Freer asked 16/9, 2015 at 14:54
6
Solved
From what I can find on google, VB.NET only has one-statement lambdas, and not multi-statement anonymous functions. However, all the articles I read were talking about old versions of VB.NET, I cou...
Healy asked 22/3, 2009 at 21:19
6
Solved
I was wondering if this actually worked ?
private void RegisterKeyChanged(T item)
{
item.OnKeyChanged += (o, k) => ChangeItemKey((T)o, k);
}
private void UnRegisterKeyChanged(T item)
{
ite...
Richman asked 12/1, 2010 at 18:27
2
I've got some unexpected access violations for Delphi code that I think is correct, but seems to be miscompiled. I can reduce it to
procedure Run(Proc: TProc);
begin
Proc;
end;
procedure Test;
b...
Epic asked 4/9, 2013 at 8:18
1
Solved
In an excellent answer about starting a timer immediately, I could see the following code:
timer.Elapsed += timer_Elapsed;
ThreadPool.QueueUserWorkItem((_) => DoWork());
...
void timer_Elaps...
Hash asked 6/2, 2015 at 10:12
1 Next >
© 2022 - 2024 — McMap. All rights reserved.