Browsing 7239 questions and answers with Jon Skeet
You should use a Map<String, String> instead: private static final Map<String, String> DRIVE_MAPPINGS = new HashMap<>(); static { DRIVE_MAPPINGS.put("p", "\\\\fs-innova1\\projects\\"); DRIVE_MAPPINGS.put("h",... more 10/30/2013 5:33:33 PM
Well I don't know anything about CharConverter or AS400Text, but code like this is almost always a mistake: String s = new String(bytes); That uses the platform default encoding to convert the binary data to text. Usually storage and... more 10/30/2013 5:16:03 PM
Can I use the same comparator to sort the list by Id too? Well you could have a constructor parameter to say which property you want to sort by - but personally I'd create a different class for that instead. You can have as many... more 10/30/2013 4:18:46 PM
Yes, it makes sense for it to be static. That signifies your intention, prevents clients from even declaring a variable of that type, etc. You'll need to move the const modifier before the type part though: public const string MyConst1 =... more 10/30/2013 3:54:17 PM
My question is what exactly does lock(typeof(string)) do? It locks on the Type object referred to by the reference that the typeof operator returns. That means any code which does the same thing anywhere within the same process (or... more 10/30/2013 3:45:48 PM
Well you can use File.ReadAllLines instead - that will read the whole file into a string[] rather than reading it line by line, but you're reading the whole thing into memory anyway due to the ToArray call, so it's just a bit less... more 10/30/2013 3:25:11 PM
Is it so because I am defining a private constructor and then trying inherit the class in other class? Yes. If your only constructors are private, then you can't create a subclass of that class, as there would be no accessible... more 10/30/2013 11:13:40 AM
You're asking for the difference in years, months and days - so you're getting back 1 year, 10 months and 29 days. Just use: int months = Months.monthsBetween(date1, date2).getMonths(); Or if you really want to use new Period and... more 10/30/2013 9:00:38 AM
But I can't return non-void value from this method Yes you can, but it has to be Task or Task<T> for some T. So you can change your method to: public async Task<BitmapImage> GetThumbImageFromFile(StorageFile... more 10/30/2013 8:23:29 AM
This is the problem: new SimpleDateFormat("yyyy-MM-dd hh:mm:ss") The hh here means "12 hour hour-of-day" so 12 means midnight unless there's something to indicate that it's meant to be 12 PM. Your value of 13 only works because the... more 10/30/2013 7:14:51 AM