Browsing 7239 questions and answers with Jon Skeet
You're hashing different data - in Java you're converting the string to UTF-16: digest.update(str.getBytes("UTF-16LE")); In C# you're using UTF-8: byte[] data = new UTF8Encoding().GetBytes(str); (I'm not sure why you're creating a... more 9/8/2017 8:12:26 AM
You can't specify null as a value of type T because it might not be a valid value for T. (Think int etc.) However, you can use default(T), which will be the default value for T - the same value you'd get if you left a field of type T... more 9/8/2017 7:10:15 AM
How I'd approach this would depend on exactly what you need to do. In Noda Time 2.0 (and backported to 1.4) there's an IWeekYearRule interface you could implement, if you want to do this thoroughly. If you just need to compute the year... more 9/7/2017 8:53:54 AM
I think you should avoid the string conversion entirely. It's pointless and error prone. It's much simpler just to do the maths: public static DateTime Int32ToDateTime(int value) { int year = value % 10000; int day = (value /... more 9/6/2017 5:42:02 PM
I don't know anything about T4 generation specifically, so I can't help in terms of halting the generation process with a useful message, but you may find it's better just to generate a #error pragma, e.g #error No configuration found for... more 9/6/2017 8:10:11 AM
Nothing, because it's a list of an anonymous type. The very term "anonymous type" was chosen because the type doesn't have a name. If you want to be able to use explicit typing, don't use an anonymous type. Either create your own type, or... more 9/5/2017 1:41:44 PM
Yes, both of them are read-only, but there is a difference. In the first one, there's a backing field which is initialized to 0 before the constructor is executed. You can change the value only in the constructor, just like a regular... more 9/5/2017 5:46:18 AM
The issue you linked to is about users logging in via MVC. If you want to use a service account: If your server is on Google Cloud (e.g. Compute Engine, Container Engine or App Engine) you shouldn't need to do anything Otherwise,... more 9/4/2017 2:57:41 PM
SelectMany is indeed what you want: var list = numbers.SelectMany(n => new IMyObj[] { new MyObj1(n), new MyObj2(n) }) .ToList(); In other words, for each number, create a two-element array, which is then flattened... more 8/30/2017 12:51:00 PM
Double.valueOf expects a value formatted with a dot as a decimal point, always. You're creating a DecimalFormat that uses the system default locale, and the . there is the locale-specific decimal separator. The smallest change that might... more 8/30/2017 6:17:02 AM