Browsing 7239 questions and answers with Jon Skeet
No, you can't call an extension method on a method group or on an anonymous function. Section 7.6.5.2 of the C# specification requires that: An implicit identity, reference or boxing conversion exists from expr to the type of the... more 7/27/2016 9:35:59 PM
The calendar you're using is fine - you just need to remember that a Date only stores an instant in time. It doesn't remember a calendar, time zone or text format. The Date value you've got is correct - it has an epoch millis of... more 7/27/2016 4:15:44 PM
You have this structure: while (true) { try { // Code which writes one line } finallly { out.close(); } } In other words, you're closing the output after the first line, but continuing to do work. That's not... more 7/27/2016 3:11:59 PM
Look at the whole if/else: if (s.equals(key)) { ... } else if (s == null) { ... } If s is null, then s.equals(key) will have thrown a NullPointerException - so you'll never get into the second if block. You should use a... more 7/25/2016 8:40:41 PM
What is the reason behind such error? Because it is trying to store a Camel into an array with a runtime type of Bear[]. An array of type Bear[] can only store references to instances of Bear or subclasses. The compile-time type of... more 7/25/2016 1:39:34 PM
You're creating a single instance of Coords, and adding a reference to that single object every time addCell is called, after mutating it. You should create a new instance of Coords each time, e.g. // Remove the cellCoords field private... more 7/25/2016 9:23:15 AM
The problem is that your NodeCoordinate class doesn't define equality in a way that the dictionary would use. You have a method like this: public bool Equals(NodeCoordinate coord) ... but you neither override... more 7/24/2016 2:53:59 PM
I don't care what month/year/day is asigned, i only want the time. That suggests you should be parsing it as a LocalTime, given that that's what the string actually represents. You can then add any LocalDate to it to get a... more 7/23/2016 1:10:15 PM
Well yes, but you need to use the Value property to "un-null" it: int d3 = (int)(d1 - d2).Value.TotalDays; However, you should consider the possibility that either d1 or d2 is null - which won't happen in your case, but could in other... more 7/23/2016 12:30:59 PM
Just use Enum.IsDefined: public static MyEnum GetEnum(int value) => Enum.IsDefined(typeof(MyEnum), value) ? (MyEnum) value : MyEnum.Undefined; Complete example: using System; public enum MyEnum { // Moved here as it's more... more 7/23/2016 1:21:09 AM