Browsing 7239 questions and answers with Jon Skeet
select is for projections, not filtering. It sounds like you want a where clause instead. I'd suggest not using query expressions here, given that you're only doing simple things: var query = db.Periods .Where(p =>... more 10/17/2016 5:58:11 AM
Why can't the runtime use the user-defined type conversion operator in the second method call? Because the compiler isn't executing at execution time... user-defined conversions are noticed by the compiler, not the runtime. The cast... more 10/16/2016 6:50:49 PM
You're opening a new FileOutputStream on each iteration of the loop. Don't do that. Open it outside the loop, then loop and write as you are doing, then close at the end of the loop. (If you use a try-with-resources statement with your... more 10/14/2016 8:59:29 PM
In both cases, these are constant variables as defined in JLS 4.12.4. So not only are the strings "doSomethingmetrics" and "saySomethingmetrics" interned, but so are "Metrics for doSomethingmetricsis something" and "Metrics for... more 10/12/2016 8:55:31 PM
.NET isn't terribly good when it comes to iterating over Unicode characters instead of UTF-16 code units. All the relevant code is there, but it's not terribly easy to use. It's possible that Regex can be made to understand surrogate... more 10/12/2016 8:33:06 PM
You need DateTimeZone.GetUtcOffset(Instant): public static int ConvertFromTimeZoneToMinutesOffset(string timeZone, IClock clock) { DateTimeZone zone = DateTimeZoneProviders.Tzdb[timeZone]; Offset offset =... more 10/12/2016 8:06:54 PM
Two are left after that. Each -= only removes one subscription. At least, that's the case if it's using just a regular delegate to back the event. You can see this easily without really involving events: using System; public class... more 10/12/2016 6:43:13 PM
You're still returning the data as base64 text, basically - you're getting the UTF-8 encoded form of it, but that's all. If you really only have the base64 version of the image, you just need to decode that: byte[] image =... more 10/12/2016 9:16:51 AM
You're comparing c - a char, which is an unsigned type - with -1. Don't do that. It's promoting c to int, so you'll end up with 65535 instead. Instead, make c an int and do the cast to char inside the body of the loop. int c; while ((c =... more 10/11/2016 2:27:47 PM
The difference is simply that by initializing PropertyChanged with a no-op delegate to start with, you don't need to worry about whether or not the delegate is null due to there being no subscribers. Before C# 6, the "check whether or not... more 10/10/2016 11:57:30 AM