You searched for jon skeet. We found 71 results in 0.380 seconds.

Should i prefer readability over safety in my code?

I am dealing with some code that has consistent pattern of creating Map instances like this: Map<String, String> valuesMap = new HashMap<String,...
Jon Skeet
people
quotationmark

Despite the various comments, I've seen helper methods like this used quite a bit, for static initialization, and usually found them simpler than alternatives. Of course, it only works when your key and value type are the same - otherwise... more

people

Comparing GenericTypeDefinition of interfaces

Simple code that I expect List<int>'s GenericTypeDefinition to contain a generic interface of ICollection<>. Yet I can't derive an acceptable type from List<int>...
Jon Skeet
people
quotationmark

No, the generic type definition will refer to ICollection<T> specifically, where T is the type parameter for the IList<T>. Imagine you had something like: public class Foo<T1, T2> : IEnumerable<T1>,... more

people

NodaTime usage for datetimepicker

To avoid label of duplicate here's a brief summary of all what i did. After spending hours of googling to calculate the difference between two dates I came across here and here...
Jon Skeet
people
quotationmark

You're performing three separate computations here. You only need one: var appointment = LocalDateTime.FromDateTime(dateTimePicker1.Value).Date; var retirement = LocalDateTime.FromDateTime(dateTimePicker2.Value).Date; var difference =... more

people

Best way to compare Periods in using NodaTime (or alternative)

I have a requirement to have a relative min/max date validation able to be stored in a database to customize an application per customer. I decided that the NodaTime.Period due...
Jon Skeet
people
quotationmark

Just as an additional point to Matt's already-excellent answer, we provide an option for creating an IComparer<Period> with a specific anchor point, e.g. var febComparer = Period.CreateComparer(new LocalDate(2015, 2,... more

people

Hebrew rendering in website

I am working on a product which has an internet "Admin Panel" - Somewhere the user can see information about the product. One of the minimal requirements is that the website has...
Jon Skeet
people
quotationmark

Basically, don't use FileReader. It always uses the platform-default encoding, which may well not be appropriate for this file. If you're using a modern version of Java, it's better to use: Path path =... more

people

Bitwise or operator used on a sign extended operand in Visual Studio 2015

I just tried installing Visual Studio 2015, and when trying to compile an old project, I got the warning CS0675 Bitwise-or operator used on a sign-extended operand; consider ...
Jon Skeet
people
quotationmark

Sign extension is happening, but possibly not for the obvious reason, and not in a worrying way, IMO. This code: a |= (short) b; is equivalent to: // No warning here... (surprisingly, given that `a` is being sign-extended...) a =... more

people

How to model HashMap/Dictionary in the ProtoBuf efficiently

I have a protobuf file serialized by .NET code and I would like to consume it into Java. In the .NET code, there is Dictionary data type and the proto schema looks like message...
Jon Skeet
people
quotationmark

Well, maps are already supported in "protobuf proper" as of v3.0. For example, your proto is effectively: message Dictionary { map<string, string> pairs = 1; } The good news is that with the key and value fields you've... more

people

Retrieve list of possible DateTime formats from string value

I would like to be able to parse date and/or date-time values from a csv file and get their DateTime format (or in Excel terms NumberFormat). For example I would like to pass...
Jon Skeet
people
quotationmark

There's no such thing as "all possible date formats". A format of "'Year:' yyyy 'Month:' MM 'Day:' dd" would be valid, but highly unusual, for example. There's nothing that Noda Time supplies here that would be particularly helpful. I... more

people

Does Action<T> prevent enclosing class instance to be GCed when all other references to class instance are removed?

I wonder whether Action<T> prevents an enclosing class instance to be garbage collected when all other references to such class instance are removed during runtime? public...
Jon Skeet
people
quotationmark

I wonder whether Action<T> prevents an enclosing class instance to be garbage collected when all other references to such class instance are removed during runtime? No. If the delegate instance were still referenced elsewhere,... more

people

Why does the compiler choose override with IEnumerable over IEnumerable<T>?

Consider the following two extension methods: using System; using System.Collections.Generic; using System.Linq; public static class Extensions { public static bool...
Jon Skeet
people
quotationmark

My question is, why does the compiler choose my Contains() method with non-generic IEnumerable argument over Enumerable.Contains<T>() with IEnumerable<T> argument? Because it's found in the same namespace that contains the... more

people