Browsing 7239 questions and answers with Jon Skeet
Sergey's solution of explicitly using a culture which uses the Persian calendar should work, but another option is to use my Noda Time library: using System; using System.Globalization; using NodaTime; using NodaTime.Text; public class... more 8/28/2014 6:20:34 AM
I can replicate the problem for the lambda example. When I run the app on a 4.0 and 4.5 server it behaves the same. If you mean the change in behaviour in C# when it comes to capturing the iteration variable in a foreach loop, that is... more 8/28/2014 5:59:12 AM
Is there any performance difference for either way? Yes - the second is marginally slower, due to a pointless instance being constructed. I know the first way of doing it here is accessing it properly. But the second way only... more 8/27/2014 10:32:06 PM
I don't see how this is possible, seeing as colors can never be modified after it's initialization. It's a view on the dictionary's keys... and you're modifying the dictionary here: colorDictionary[c]--; Admittedly that's not... more 8/27/2014 9:51:59 PM
Just create the DateTimeFormatter explicitly: DateTimeFormatter formatter = DateTimeFormatter.ofPattern("HH:mm:ss", Locale.US); LocalTime time = LocalTime.now(); String f = formatter.format(time); System.out.println(f); (I prefer to... more 8/27/2014 8:46:32 PM
My base64 string looks like this on the java and javascript side: [B@74193bd0[B@24a6103c That's not base64. That's the concatenation of the result of calling toString() on two byte arrays. You're using a method which returns a byte[],... more 8/27/2014 7:58:55 PM
Once you've got a class which implements IEquatable<T> or IEqualityComparer<T>, it's easy to do the rest with Except and Any: if (collectionA.Except(collectionB).Any()) { // There are elements in A which aren't in... more 8/27/2014 7:56:00 PM
Well you're missing the fact that Concat will throw an exception if you pass it a null reference... but it's easy enough to fix. Either write an extension method like this: public static IEnumerable<T> NullToEmpty<T>(this... more 8/27/2014 7:48:47 PM
No, there's nothing like that, as far as I'm aware. I wouldn't put it past different companies to have different ideas of "Q1" and "H1" to start with, to be honest - such as "Q1 ends at the end of the last week which starts in... more 8/27/2014 5:41:37 PM
Well, it's using both heap and stack. The stack space is because you're in the constructor for A, recursively. It would be simpler to see this if you put the initialization in the body of the constructor: public class A { A aa; ... more 8/27/2014 4:26:05 PM