Browsing 7239 questions and answers with Jon Skeet
It feels to me like it should just be looping: while (true) // Or probably have a maximum number of retries { try { // Logic // Break out of the loop by returning if we succeed return; } catch... more 11/21/2013 1:59:41 PM
You can use an iterator for this: for (Iterator<String> iterator = source.iterator(); iterator.hasNext(); ) { String element = iterator.next(); if (shouldDrain(element)) { destination.add(element); ... more 11/21/2013 1:57:28 PM
It's not really clear what you mean by "do kinda the opposite" but: static IsThirdMondayInMay(DateTime date) { // The first X in a month is always in the range [1, 8) // The second X in a month is always in the range [8, 15) ... more 11/20/2013 12:41:41 PM
Just don't name a type the same as its namespace. That's always a bad idea. You can get round the issues in various ways, but it's ugly in many cases. Renaming either the type or the namespace would be much better. In this particular... more 11/20/2013 12:10:11 PM
Using BufferedWriter.write() when is a file created? Never. BufferedWriter itself just writes to another Writer. Now if you're using a FileOutputStream or a FileWriter (where the first would probably be wrapped in an... more 11/20/2013 11:42:49 AM
My Noda Time library is built for exactly this sort of thing: LocalDate start = new LocalDate(...); LocalDate end = new LocalDate(...); Period period = Period.Between(start, end); Console.WriteLine("{0} years, {1} months, {2} days", ... more 11/20/2013 11:29:37 AM
after parsing the date through simpledateformat Wed Nov 20 14:00:00 IST 2013, here i passed the HH and MM as 08 30 but after parsing it changed to 14:00:00 Yes, because you specified that you wanted it to be parsed as a UTC value.... more 11/20/2013 5:21:34 AM
What is happening here? Both arguments are being boxed, to different objects. Imagine your code is actually this: int? k = 10; object x = k; // Boxing operation 1 object y = k; // Boxing operation 2 Assert.IsTrue(ReferenceEquals(x,... more 11/20/2013 5:00:15 AM
The type of this expression: y ?? true is bool, not bool?. From section 7.13 of the C# 5 spec: The type of the expression a ?? b depends on which implicit conversions are available on the operands. In order of preference, the type... more 11/20/2013 4:39:36 AM
Well yes - look at your constructor, including the clearly-inaccurate comment: // four-argument constructor public SalariedEmployee(String first, String last, String ssn, Date DayOfBirth, String ID, double... more 11/20/2013 3:44:20 AM