Browsing 7239 questions and answers with Jon Skeet
By implementing ToString(string format, IFormatProvider formatProvider) explicitly, you can only call it via a reference with a compile-time type of IFormattable. You can do that by using this: return... more 8/7/2015 10:00:23 AM
Task<T> extends Task - so it's reasonably common to just use Task.FromResult<object> and provide an empty result. For example: Task ret = Task.FromResult<object>(null); (Or use a value type - it really doesn't matter... more 8/7/2015 9:40:50 AM
I agree this is something which is basically missing. While it's only useful in rare cases, I think they're significant rare cases - most notable, key canonicalization. I can only think of one suggestion at the moment, and it's truly... more 8/7/2015 7:48:37 AM
Basically, it's just a matter of reading through JLS 12.5 (Creation of New Class Instances) carefully. In particular, note the order of: Execute the instance initializers and instance variable initializers for this class [...] ... more 8/7/2015 6:22:32 AM
The point of a join is to find matching elements in two independent data sources. In other words, the elements in the right hand side of the join can't depend on the element on the "current" left hand side of the join. So you can't join... more 8/7/2015 6:04:04 AM
I suspect you haven't seen that exact syntax. Look at what you've got: db.Parameters.Add(new SqlParameter("@pID", SqlDbType.Int).Value = 12345); That's calling db.Parameters.Add with an int argument. I suspect what you've actually seen... more 8/6/2015 6:59:44 PM
It seems that HashMap doesn't use the equals method (I may be wrong, if so my tests are wrong). It does use equals, but it uses hashCode first. It will only bother calling equals on keys with the same hash code - that's how it manages... more 8/6/2015 4:05:24 PM
I suspect you're running into a problem due to the T in ICollection<T> being different in each case. Here's a short but complete example: using System; interface IFoo<T> {} public class Foo1<T> : IFoo<T>... more 8/6/2015 2:26:58 PM
There's nothing new here, really. Forget automatically implemented properties - you simply can't refer to this within a field initializer. (Let's face it, you're trying to initialize a field under the hood - just a field which is only... more 8/6/2015 12:39:31 PM
You're using // at the start of each of your selections - which means "find descendant nodes starting at the root" (so the context is irrelevant). You could either do things in one step as per Jeffrey's answer, or use relative... more 8/6/2015 12:24:51 PM