anonymous-methods

Declaring func<in T,Out Result> dynamically

Consider this: var propertyinfo = typeof(Customer).GetProperty(sortExpressionStr); Type orderType = propertyinfo.PropertyType; now i want to declare Func<int,orderType> i know its not possible directly since ordertype is at runtime but is there is any workarround ? this is exactly what i want to do : var propertyinfo = t...

How do delegate/lambda typing and coercion work?

I've noticed some examples of things that work and don't work when dealing with lambda functions and anonymous delegates in C#. What's going on here? class Test : Control { void testInvoke() { // The best overloaded method match for 'Invoke' has some invalid arguments Invoke(doSomething); // Cannot convert ...

Avoid or embrace C# constructs which break edit-and-continue?

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 of as a perpetual beta), and there's very little done to shield users from potential new bugs that might be introduced in a weekly build. For ...

Discrete Anonymous methods sharing a class?

I was playing a bit with Eric Lippert's Ref<T> class from here. I noticed in the IL that it looked like both anonymous methods were using the same generated class, even though that meant the class had an extra variable. While using only one new class definition seems somewhat reasonable, it strikes me as very odd that only one instance...