Browsing 7239 questions and answers with Jon Skeet
Or am I confusing matters? You are. I think it's much simpler to think about precedence as grouping than ordering. It affects the order of evaluation, but only because it changes the grouping. I don't know about Javascript for sure,... more 9/30/2017 7:07:14 PM
You're essentially flattening to a sequence of the struct values - and that flattening is represented with SelectMany. So you want: var res = dict.Values .SelectMany(x => x.listSrc) .Where(ls => ls.A > 3) .Select(ls... more 9/30/2017 9:35:56 AM
Well you won't be able to do it quite like that, but you could write: await LockWrapper(() => Work1(modelInstance)); and write LockWrapper as: private async Task LockWrapper(Func<Task> taskProvider) { await... more 9/30/2017 9:04:09 AM
It sounds like you just want: if (inputDate == null || inputDate.getTime() == 0L) That will detect if inputDate is null or represents the Unix epoch. As noted in the comments though: Rejecting a single value is kinda dangerous - why... more 9/29/2017 4:39:41 PM
I'm trying to generate a timestamp using C# DateTime.Now. It's strongly recommend against doing that. That will use the time zone of the system where the code is running. It's just not suitable for a timestamp. In... more 9/29/2017 1:57:06 PM
Note: this answer aims at "trial completely contains event" - for "trial overlaps event", see Matt Johnson's answer. OffsetDateTime.ToInstant is unambiguous, so you could certainly just convert to Instant values. You might want to create... more 9/29/2017 1:43:26 PM
You don't need to write a complex regex - you can build a DateTimeFormatter that will work with that format easily: DateTimeFormatter formatter = DateTimeFormatter.ofPattern("uuuu-MM-dd'T'HH:mm:ss.SSSX", Locale.ROOT); OffsetDateTime... more 9/29/2017 11:08:05 AM
It sounds like you're just looking for the convert method: Converts the given time duration in the given unit to this unit. return unit.convert(24, TimeUnit.HOURS) / cycleDuration; more 9/28/2017 9:39:24 PM
Basically, you shouldn't use HasFlag for a non flags-based enum... and a flags-based enum should use a separate bit for each flag. The problem is indeed because of the values. Writing this in binary, you've got: public enum TestEnum { ... more 9/27/2017 2:02:23 PM
This has nothing to do with it being a weak map, and everything to do with you modifying a map key, which is basically something you should avoid doing. By adding an entry to the map, you're changing its hash code. This is easily... more 9/27/2017 9:17:00 AM