Browsing 7239 questions and answers with Jon Skeet
It sounds like you possibly want an inner join: var query = left.Join(right, l => l.Id, r => r.Id, (l, r) => new { l.Id, l.Name, r.Qty1, l.Qty2 }); (You may want to join on both Id and Name; it's not clear... more 2/1/2015 9:07:11 AM
There are three ways of directly creating a new object in C#: A simple constructor call with an argument list: new Foo() // Empty argument list new Foo(10, 20) // Passing arguments An object initializer with an argument list new... more 1/31/2015 5:40:28 PM
Is there some way to make sure that anything in Parallel.For always run on separate thread so that main thread is always free. Parallel.For will always block until everything is finished - so even if it didn't do anything on the... more 1/31/2015 3:20:49 PM
Firstly, you're using SingleOrDefault which will only select a single value. You want to use Sum instead. Also, you don't need an anonymous type here. You can just use: var result = (from t1 in _dbEntities.Charges join t2 in... more 1/31/2015 2:45:18 PM
The simplest way is probably to just generate 16 values: Set<Integer> addOnlyTwoPrefixes(int base) { return IntStream.range(0, 16) .map(prefix -> base * 100 + // Leading digits 10 + 10 *... more 1/31/2015 12:13:38 PM
You could use TakeWhile and LastOrDefault: var meeting = Meetings.TakeWhile(m => !m.Selected) .LastOrDefault(); if (meeting != null) { // Use the meeting } else { // The first meeting was selected, or... more 1/30/2015 2:57:53 PM
The second parameter to substring is an exclusive upper bound - so it's allowed to be equal to the length of the string, in order to include the last character. Likewise it makes sense to allow the starting point to be "at" the end of the... more 1/30/2015 2:26:37 PM
You're calling c.getClass().getPackage() when you should be calling c.getPackage(). c is already the superclass - it's a Class, so calling getClass() on it will just give you Class.class, which isn't what you want. I would try to be more... more 1/30/2015 10:43:54 AM
In order to safely convert arbitrary binary data into text, you should use something like hex or base64. Encodings such as UTF-8 are meant to encode arbitrary text data as bytes, not to encode arbitrary binary data as text. It's a... more 1/30/2015 10:29:09 AM
If you want to pass a BCL time zone to Noda Time, you just need to use the BCL provider: DateTimeZone _zone = DateTimeZoneProviders.Bcl[zoneId]; This will find the relevant TimeZoneInfo, extract its adjustment rules, and convert that... more 1/30/2015 6:58:56 AM