Browsing 7239 questions and answers with Jon Skeet
In the second case, you're constructing a Date and then telling it to format that date in UTC - whereas in the first case, you're parsing it in UTC, but formatting it in local time. You're already assuming that the timestamp is stored as a... more 6/8/2016 1:17:54 PM
You can't declare a field inside a method. In Java, a type either has a field, or it doesn't. Every instance of the same class has the same set of fields. But you can declare the field (not in a method) and decide to only assign a value... more 6/8/2016 6:19:29 AM
The whole idea of a LinkedList is to improve such operations, while paying with reduced iteration performance. No, the idea of a linked list is to make adding or removing at the end or beginning very cheap... or if you have a... more 6/7/2016 4:30:00 PM
Look at this code: if (file.exists()) { file.delete(); file.createNewFile(); } else { file.mkdirs(); file.createNewFile(); } You're saying that if players/Player.ser doesn't exist, you should create it as a directory -... more 6/7/2016 3:54:19 PM
You're using this from an anonymous inner class - so it refers to the instance of that anonymous inner class. There are two different instances (of different anonymous inner classes) so you're calling wait() on a different object from the... more 6/7/2016 7:32:16 AM
No - the whole point of the restriction on covariance is that it guarantees safety. A PersonRepository isn't an IRepository<DomainBase> because you can't ask it to persist any arbitrary DomainBase object. What would you expect this... more 6/6/2016 8:08:30 PM
Task<T> is a class, and therefore invariant. So a Task<string> is not a Task<object> - and as a more complicated example, a Task<IEnumerable<IPurchasedItem<Apple>>> is not a... more 6/6/2016 7:59:21 PM
Or does the compiler knows only the type of the reference, not of the object (in the memory) itselfs? It only knows the type of the expression that you're trying to cast. That expression is of type Object, so it's fine to cast it to C... more 6/6/2016 11:47:04 AM
It's "whatever object the method was called on". We can't tell where the object is created, because that's presumably in some other code. Have a look at this simple, complete example: class Person { private final String name; ... more 6/6/2016 6:19:31 AM
I don't think you're going to be able to do this directly, but you could easily use reflection to create the instance: Type openType = TIsAReferenceType ? typeof(SomethingForReferenceTypes<>) :... more 6/5/2016 5:00:07 PM