Browsing 7239 questions and answers with Jon Skeet
Thanks to <T extends SomeType>, we can be sure that T is always a subtype of SomeType, right? Right. So why can't I just return the supertype SomeType? Because it might not be a T! Put it this way - imagine SomeType is... more 8/9/2014 7:27:08 AM
Your two methods are extension methods, which are meant to look like instance methods when they're called. They can be called statically, but you need to supply the instance as the first argument, and specify the class which declares the... more 8/8/2014 9:09:30 PM
No. Enum members have to be valid identifiers. From section 14.3 of the C# 5 specification: The body of an enum type declaration defines zero or more enum members, which are the named constants of the enum type. No two enum members can... more 8/8/2014 8:28:56 PM
You're using BinaryWriter.Write(int). So yes, it's writing 4 bytes, as documented. If you only want to write one byte, you should use BinaryWriter.Write(byte) instead. So you probably just want: bin.Write(Convert.ToByte(data,... more 8/8/2014 3:22:59 PM
Yes, this is due to zone1970.tab only being introduced in 2014f, and the released TzdbCompiler not knowing about it. Delete the file, and you should be fine - or you can just use the nzd file we've already put up on the web site. If... more 8/8/2014 2:20:50 PM
Assuming your loop is meant to use x.size(), then it's pretty simple - if x.size() is 0, you'll be computing 0/0, which is NaN. Otherwise, it could be that logicWhichReturnsPrimitiveDouble() returns a NaN for whatever reason. It's not... more 8/8/2014 2:10:46 PM
It sounds like your timestamp format is probably in seconds since the Unix epoch, instead of the milliseconds that Java expects - so just multiply it by 1000: Date date = new Date(jsonObject.getLong("release_date") * 1000L); You should... more 8/8/2014 1:21:48 PM
Currently your first option doesn't check for the group ID, but that's easily fixed: return groups.Where(g => g.GroupId == groupId) .SelectMany(g => g.Items) .FirstOrDefault(i => i.ItemId ==... more 8/8/2014 12:27:12 PM
Ideally, you should keep the type information all the way through the system - and potentially create a named type with the relevant properties. You could then cast back to IEnumerable<SomeConcreteType> later. If you can't do that... more 8/8/2014 12:18:28 PM
It's failing to parse because you've got a space in there for no particular reason. Look at the string it's trying to parse, and you'll see it's not a valid number. If you're just trying to add extra trailing zeroes (your question is very... more 8/8/2014 12:01:43 PM