Browsing 7239 questions and answers with Jon Skeet
The problem is that you're trying to build a Func<T, int> but your call to Expression.Lambda doesn't specify the parameter expression, which means you can't expect it to create a delegate that has any parameters. Just specifying type... more 12/17/2015 10:34:58 AM
Most of those characters simply aren't valid in XML 1.0 at all. Personally I wish that LINQ to XML would fail to produce a document that later it wouldn't be able to parse, but basically you should avoid them. I would also recommend... more 12/17/2015 9:56:16 AM
If you're looking for the type arguments for a specific class, that's relatively easy: static Type GetDatabaseTypeArgument(Type type) { for (Type current = type; current != null; current = current.BaseType) { if... more 12/17/2015 7:25:10 AM
Yes, the variable is captured by the lambda expression, and you're then modifying it. There are a few simple options: First, copying the variable to a variable which is instantiated within the loop: for (int i = 0; i < list.Count;... more 12/17/2015 6:58:18 AM
You simply haven't imported it - you either need a wildcard import: import java.io.*; or the specific import: import java.io.FileReader; As noted by Titus, you're also missing a new before you use FileReader.... more 12/17/2015 6:43:43 AM
The static initializer of all the classes have started executing - but in order to initialize D, C must be initialized, so B must be initialized, so A must be initialized. At the point where the code in the static initializer in A is being... more 12/16/2015 2:22:58 PM
Your subclass should override Dispose(bool disposing) if anything - that's the whole point of having that method at all, really. However, I suspect that the base class will make the right calls anyway, so you shouldn't need to do... more 12/16/2015 12:01:05 PM
Two options: Use dynamic typing, so long as you're using it from the same assembly: dynamic values = GetValues(); var a = values.a; //etc Use reflection directly; the generated type will have public read-only properties called a, b, c... more 12/16/2015 10:59:26 AM
You have a property, which, when you execute the "get" accessor, finds all the properties and fetches their value. So it executes itself, recursively. If you only want string properties, you should check the property type before fetching... more 12/16/2015 10:51:10 AM
Why can't I just use mailObject.GetAttachments() after I check if it implements the interface (or baseclass for that matter) with is? Because the compile-time type of the mailObject variable is still just T. Note that currently... more 12/16/2015 10:23:47 AM